Community
Participate
Working Groups
Using build I20051116-1332. Here's my projects setup: Project 'P' <default package> Test.java public class Test { <TP extends Test> void m(Test methodParam) { Test localVar; for (java.util.List<Test> localVar2;;) { } } } Project 'Test' b110336 Test.java package b110336; public class Test { // This class is empty (created using wizard...) } Now here's the story... I had a class Test in default package in a project 'P'. I created a new class 'Test' in package b110336 in another project 'Test'. As I used the wizard to create this class, I had an editor opened on this new empty class. Then, I wanted to copy my test class Test.java of project 'P' in package b110336 of project 'Test'. So I used 'Copy' menu item on project 'P' Test.java class, selected package b110336 of project 'Test' and clicked on 'Paste' menu item... I was asked if I wanted to overwrite the exisiting destination and I answered yes. But result was really strange as I saw in the opened editor a duplicate line: package b110336; of course flagged as error... I wanted to cancel this change and closed the opened editor, then I got a message saying that file has been changed on file system. I loaded changes and then got the content of project 'P' class Test without the package declaration. Of course all class contents was flagged as error due to the fact that the declared package does not match the expected one... It seems that package declaration insertion was done on working copy of opened editor instead of contents pasted from copied CU...
Markus, can you have a look?
Looks like a problem in ICompilationUnit#copy(..). Moving to JDT/Core. We call that method on P/Test.java and copy it to the package b110336 with force==true. Right when that call comes back, the buffer of the ICompilationUnit Test/b110336/Test.java contains the two package declarations. The copy operation should only change the contents of the working copy and not touch the file system.
Created attachment 31769 [details] Proposed patch and regression test
Released fix and regression test to HEAD
Verified for 3.2 M5 using build I20060214-0010.