Bug 153213

Summary: [compiler] Annotation code compiles by Eclipse compiler but not by JDK compiler
Product: [Eclipse Project] JDT Reporter: Dmitri Maximovich <maxim>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Dmitri Maximovich CLA 2006-08-08 22:58:20 EDT
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 {
}
==============================
Comment 1 Frederic Fusier CLA 2006-08-09 04:40:45 EDT
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...
Comment 2 Olivier Thomann CLA 2006-08-15 13:25:52 EDT
Closing as a dup of bug 138443.

*** This bug has been marked as a duplicate of 138443 ***