Bug 284088 - [1.5][compiler] parser problem with trailing comma in array list in annotation
Summary: [1.5][compiler] parser problem with trailing comma in array list in annotation
Status: VERIFIED DUPLICATE of bug 112433
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-21 03:27 EDT by Ulli Hafner CLA
Modified: 2009-08-05 02:24 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulli Hafner CLA 2009-07-21 03:27:22 EDT
The Eclipse compiler does not report an error for the following invalid Java annotation (trailing comma in the array initializer):

/**
 * All JUnit tests of this component.
 */
@RunWith(Suite.class)
@Suite.SuiteClasses({
    PackagerTest.class,
    MetadataMarshallerTest.class,
    PackageMetadataPackagerTest.class,
})
public final class AllTests {
    // nothing to do
}

The javac Compiler (1.6) reports the following error:

[INFO] Compilation failure
AllTests.java:[29,0] illegal start of expression
Comment 1 Stephan Herrmann CLA 2009-07-21 05:38:04 EDT
Looking at JLS §9.7 ("Annotations") the trailing comma is actually legal:

    ElementValueArrayInitializer:
        { ElementValuesopt ,opt }

    ElementValues:
        ElementValue
        ElementValues , ElementValue

(see the ",opt": optional comma)

Also the full grammar in §18.1 states:

    ElementValueArrayInitializer:
        { [ElementValues] [,] }

Unless I'm missing something the difference is a bug in javac, not Eclipse.
Comment 2 Olivier Thomann CLA 2009-07-21 07:11:18 EDT
Yes, this is a javac bug. We already have a dup for this one. I'll try to find it later.
Comment 3 Olivier Thomann CLA 2009-07-22 15:51:36 EDT
Closing as a dup of bug 112433.

*** This bug has been marked as a duplicate of bug 112433 ***
Comment 4 Jay Arthanareeswaran CLA 2009-08-05 02:06:15 EDT
Verified for 3.6M1