Bug 153213 - [compiler] Annotation code compiles by Eclipse compiler but not by JDK compiler
Summary: [compiler] Annotation code compiles by Eclipse compiler but not by JDK compiler
Status: RESOLVED DUPLICATE of bug 138443
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-08 22:58 EDT by Dmitri Maximovich CLA
Modified: 2006-08-15 13:25 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***