Community
Participate
Working Groups
JLS3 states on page 283 that for annotations: Note that null is not a legal element value for any element type. However the following is allowed in eclipse 3.1M4: public @interface Foo { int[] bar() default null; } also, null is incorrectly allowed in the following context: @Foo(bar=null) int baz; javac-1.5.0 fails in both of these cases.
With latest I get: ---------- 1. ERROR in c:\tests_sources\X.java (at line 3) int[] bar() default null; ^^^^ The value for annotation attribute X.bar must be a constant expression ---------- 1 problem
Closing as WORKSFORME. Added regression test. Thanks for reporting the problem.
well, that's what i get for trying to simplify my testcase without actually checking in eclipse. here's the real reproducer. sorry for the confusion. @interface Foo { } @interface Bar { Foo[] foo() default null; } @Bar(foo=null) class Blah { // ... }
I'll try to reproduce.
Created attachment 17566 [details] Test case
Indeed, we did not properly check the annotation value scenario. Added AnnotationTest#test108-109.
Fixed
Verified in I20050214