Bug 130778 - Invalid annotation elements cause no annotation to be in the AST
Summary: Invalid annotation elements cause no annotation to be in the AST
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P2 normal with 2 votes (vote)
Target Milestone: 3.4 M5   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 130790 130794
  Show dependency tree
 
Reported: 2006-03-07 14:16 EST by Karen Butzke CLA
Modified: 2008-02-04 12:49 EST (History)
2 users (show)

See Also:


Attachments
falings tests for invalid annotation syntax (6.97 KB, application/x-zip-compressed)
2006-03-07 14:38 EST, Karen Butzke CLA
no flags Details
Proposed fix (164.38 KB, patch)
2008-01-25 06:52 EST, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Karen Butzke CLA 2006-03-07 14:16:34 EST
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 {}
Comment 1 Karen Butzke CLA 2006-03-07 14:38:51 EST
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.
Comment 2 Philipe Mulet CLA 2006-03-07 15:27:12 EST
Broken annotations are known to cause grief to the syntax recovery currently.
Comment 3 David Audel CLA 2008-01-25 06:52:43 EST
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.
Comment 4 David Audel CLA 2008-01-25 07:00:08 EST
Released for 3.4M5.

Tests added
  AnnotationDietRecoveryTest#test0013()->test0035()
  StatementRecoveryTest_1_5#test003()->test0007()
  ASTConverterBugsTestJLS3#testBug130778a()->testBug130778x()
Comment 5 Frederic Fusier CLA 2008-02-04 12:49:09 EST
Verified for 3.4M5 using build I20080204-0010.