| Summary: | Inconsistent Compile Result Between APT and JDK | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Emac Shen <bishen> | ||||
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> | ||||
| Status: | CLOSED DUPLICATE | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | eclipse | ||||
| Version: | 3.5.1 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 165041 [details]
a test java project
Forgot to point out that the issue appears if and only if there's an extra comma in the annotaion reference:
@MyAnnotation(transformer = { ClassA.class, ClassB.class, })
If I remove the comma, it works fine.
This is a longstanding javac bug. Eclipse is correct. The Java Language Spec (section 9.7) clearly states that the trailing comma is permitted in a list of annotations. *** This bug has been marked as a duplicate of bug 112433 *** |
Build Identifier: M20090917-0800 Given the annotation usage below (see attached project), the class is compiled well in eclipse but not in command line via javac command. public class MyClass { public static void main(String[] args) { MyClass c = new MyClass(); c.doNothing(); } @MyAnnotation(transformer = { ClassA.class, ClassB.class, }) public void doNothing() { System.out.println("Do nothing"); } } I assume eclipse APT plugin is doing some optimization in this case which leads to inconsistent results and it definitely will confuse user and break certain cases. Reproducible: Always Steps to Reproduce: 1.import the attached project 2.invoke "Project-Clean" 3.see it compiles well in eclipse. 4.open command line and navigate to the project folder 5.compile the classes using "javac" 6.see the compile fails.