Community
Participate
Working Groups
Code below compiles without any error in Eclipse but failing to compile with Sun's JDK version "1.5.0_06" and "1.5.0_07" with following error: Test.java:4: illegal start of expression }) ^ 1 error (Note extra colon in annotations list in Test.java) ========= Foos.java ========== @Target(ElementType.TYPE) public @interface Foos { Foo[] value(); } ============================== ========= Foo.java =========== @Target(ElementType.TYPE) public @interface Foo { String value(); } ============================== ========= Test.java ========== @Foos({ @Foo("1"), @Foo("2"), }) public class Test { } ==============================
For array initializer, Java spec status is: "A trailing comma may appear after the last expression in an array initializer and is ignored." Even if this is not esplicitely written for ElementValueArrayInitializer, our compiler currently supposes that this is the same behavior which should be applied for all array initializer. There was a bug opened against Sun compiler for enumeration (Bug ID: 4936392) but not for annotation. Perhaps may you open one? Philippe, I keep this bug opened and assign it to you in case you think it would be better to align eclipse compiler to Sun's compiler behavior even if it's buggy...
Closing as a dup of bug 138443. *** This bug has been marked as a duplicate of 138443 ***