Community
Participate
Working Groups
build I20050331-2000 1) create p/Annot.java package p; public @interface Annot { int foo(); } 2) create p2/X.java package p2; import p.Annot; public class X { @Annot(foo=zzz) static final int zzz = 0; } 3) compile jdtcore compiler found no error but javac found an error p\X.java:4: illegal forward reference @Annot(foo=zzz) ^ 1 error
package p2; import p.Annot; public class X { void bar(){ @Annot(foo=zzz) final int zzz = 0; } } With a local variable the behavior is the opposite. Eclipse refuse the code and produce this error message: "The value for annotation attribute Annot.foo must be a constant expression". Javac compile this code with no error.
Added AnnotationTest#test145. Initialization scope used during resolution needs to be told which field is being initialized to probably recognize forward references. Added support in 2 places: - FieldBinding#getAnnotationTagbits() - FieldDeclaration#resolve(MethodScope) Fixed
forgot to assign
fixed
Build I20050527-0010. I get initial test case OK, comment #1 test case KO. Checked that javac quietly accepts it, and we don't. Philippe, would you please comment?
I'll open a new bug for unfixed comment 1 test case...