Bug 309414 - Inconsistent Compile Result Between APT and JDK
Summary: Inconsistent Compile Result Between APT and JDK
Status: CLOSED DUPLICATE of bug 112433
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-15 23:29 EDT by Emac Shen CLA
Modified: 2010-04-16 00:12 EDT (History)
1 user (show)

See Also:


Attachments
a test java project (3.21 KB, application/x-zip-compressed)
2010-04-15 23:32 EDT, Emac Shen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Emac Shen CLA 2010-04-15 23:29:58 EDT
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.
Comment 1 Emac Shen CLA 2010-04-15 23:32:17 EDT
Created attachment 165041 [details]
a test java project
Comment 2 Emac Shen CLA 2010-04-15 23:40:50 EDT
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.
Comment 3 Walter Harley CLA 2010-04-16 00:12:26 EDT
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 ***