Community
Participate
Working Groups
Annotations with invalid syntax on the annotation elements are not found in the AST. In this first example the call to TypeDeclaration.modifiers() returns a List containing the SingleMemberAnnotation. MyAnnotation(name) class Foo {} In this example, TypeDeclaration.modifiers() returns an empty list and I am not able to see that there is an annotation on the class. MyAnnotation(name=) class Foo {}
Created attachment 35852 [details] falings tests for invalid annotation syntax This attachment contains one JUnit test class with 1 passing test and 2 failing tests. The failing tests start with classes containing the following source code and then try to get the Annotation from the TypeDeclaration. Source code contains @MyAnnotation(name=) Source code contains @MyAnnotation(name="foo" , ) More explanation is given in the test class.
Broken annotations are known to cause grief to the syntax recovery currently.
Created attachment 87852 [details] Proposed fix With this fix annotation name and all correct member value pairs are recovered. This behavior is similar to method declaration recovery (method name and all correct parameters are recovered). With the following test case MyAnnotation(name=) class Foo {} the recovered ast will be MyAnnotation class Foo {} With the following test case MyAnnotation(name1="a", name2=) class Foo {} the recovered ast will be MyAnnotation(name1="a") class Foo {} This fix also add modifiers recovery.
Released for 3.4M5. Tests added AnnotationDietRecoveryTest#test0013()->test0035() StatementRecoveryTest_1_5#test003()->test0007() ASTConverterBugsTestJLS3#testBug130778a()->testBug130778x()
Verified for 3.4M5 using build I20080204-0010.