Community
Participate
Working Groups
if i have the following code: =========================================== @Retention(RetentionPolicy.RUNTIME) @interface Foo { } =========================================== and "Organize Imports", the import for java.lang.annotation.RetentionPolicy is pulled in, but java.lang.annotation.Retention is not and i get a compile error. the code now looks like: =========================================== import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) @interface Foo { } =========================================== if i highlight Retention and select "Add Import", the import for java.lang.annotation.Retention is added correctly and the code compiles: =========================================== import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) @interface Foo { } =========================================== however if i then select "Organize Imports" option again, the import for java.lang.annotation.Retention is removed resulting in code with compile errors: =========================================== import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) @interface Foo { } =========================================== Seems to be a bug in Organize Imports.
Changed subject to reflect that the bug is related to new 1.5 features.
Jon, which build are you using.
works in latest (I20050202)
I am using 3.1M4.
Created attachment 17800 [details] Testcase
This bug is still lingering as of version I20050202-0800. If i annotate an element in package A with an annotation from package B, and then use "organize imports" to import the annotation from package B, all is well. however, if immediately do another "organize imports", the import statement for the annotation is removed. a third "organize imports" will once again import the annotation. you can toggle this repeatedly. i'm attaching a testcase. to observe the bug do the following: 1. import the annotation-test project into eclipse 2. open annotation-test/src/pkg2/Foo.java 3. Note that Foo is annotated with FooAnnotation, but FooAnnotation is not imported and this causes a compile error 4. Organize imports -- this imports pkg1.FooAnnotation (correct) 5. Organize imports again -- this removes the pkg1.FooAnnotation (incorrect) 6. Organize imports again -- this imports pkg1.FooAnnotation ... I believe that the behavior observed at step 5 is incorrect and at that point subsequent "organize import" operations should have no effect.
can you attach the archive (or the single files) again? I can't open it, it seems to be corrupted.
I found a reproducible case. The bug is in jdt.core. Filed bug 85115 for this.
*** Bug 84519 has been marked as a duplicate of this bug. ***
fixed in M5
Verified I20050217-2000