Bug 80714

Summary: Strange syntax diagnosis with incorrect annotations
Product: [Eclipse Project] JDT Reporter: David Audel <david_audel>
Component: CoreAssignee: David Audel <david_audel>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description David Audel CLA 2004-12-10 13:24:18 EST
build I20041201 + jdtcore head

1) create Test.java
@interface MyAnn {
	String value1() default "";
	String value2();
}
class ZZZ {}					
public @MyAnn("","") class Test {											
}

2) compile

The errors are the followings

The public type MyAnn must be defined in its own file
Syntax error, insert "}" to complete ClassBody
Syntax error on token "}", delete this token
Return type for the method is missing
Syntax error, insert ";" to complete ConstructorDeclaration
Syntax error, insert ")" to complete ConstructorDeclaration
Syntax error, insert ")" to complete SingleMemberAnnotation
Syntax error, insert "Identifier (" to complete ConstructorHeaderName
Syntax error on token ",", / expected
Comment 1 David Audel CLA 2004-12-10 13:27:12 EST
The problem come from modifer.

Parser#modiferSourceStart is not reinitialized when recovery restart. So when
"@interface MyAnn" is parsed the declationSourceStart of the type declaration is
wrong.
Comment 2 David Audel CLA 2004-12-10 13:39:31 EST
This bug also created InvalidArgumentException inside ASTConverter.

Fixed and test added.
  ComplianceDiagnoseTest#test0049()

the new problems is
"----------\n" + 
"1. ERROR in X.java (at line 6)\n" + 
"	public @MyAnn(\"\",\"\") class Test {		\n" + 
"	                ^\n" + 
"Syntax error on token \",\", / expected\n" + 
"----------\n";
Comment 3 Frederic Fusier CLA 2004-12-14 11:32:25 EST
Verified for 3.1 M4 using build I200412140800.