Bug 138443

Summary: compiler - annotations with arrays allow comma after last element
Product: [Eclipse Project] JDT Reporter: Darryl Smith <darryl.smith>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: marcusebner, maxim, philippe_mulet, sdavids
Version: 3.2   
Target Milestone: 3.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Darryl Smith CLA 2006-04-25 13:39:31 EDT
@Embedded
@AttributeOverrides({
    @AttributeOverride( name="city", column=@Column( name="DIAB99C_TXCTY" )),
    @AttributeOverride( name="state", column=@Column( name="DIAB99C_TXSTAT" )),
    @AttributeOverride( name="zipCode", column=@Column( name="DIAB99C_TXZIP" )),
})

compiles fine with eclipse 3.2RC1a jdt compiler.

But when using the sun jdk compiler you get
[javac] C:\..Something.java:73: illegal start of expression
[javac] })
[javac] ^
[javac] 2 errors

It would seem the JDT compiler is incorrect. And the last element in the @AttributeOverride array should not be followed by a comma
Comment 1 Olivier Thomann CLA 2006-04-25 14:34:45 EDT
I'll investigate.
Comment 2 Olivier Thomann CLA 2006-04-25 14:59:52 EDT
This looks like a bug with javac.
From http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.7, the rule from the grammar is:
ElementValueArrayInitializer:
        { ElementValuesopt ,opt }

This means that:
{ ,}
{ c , }
{ c }
{ }

are all valid ElementValueArrayInitializer elements.
They had the same bug for array initializers.
see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4396418.

You should report the bug against Sun compiler.
Closing as INVALID.
Added regression test org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest.test199
Comment 3 Olivier Thomann CLA 2006-08-15 13:25:52 EDT
*** Bug 153213 has been marked as a duplicate of this bug. ***
Comment 4 Olivier Thomann CLA 2007-01-09 11:32:13 EST
*** Bug 169963 has been marked as a duplicate of this bug. ***
Comment 5 Olivier Thomann CLA 2007-07-05 12:56:57 EDT
*** Bug 195551 has been marked as a duplicate of this bug. ***
Comment 6 Olivier Thomann CLA 2011-05-19 13:11:46 EDT
Closing as dup.

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