Bug 192774

Summary: Annotation AST nodes should have unique IAnnotationBindings
Product: [Eclipse Project] JDT Reporter: Walter Harley <eclipse>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: david_audel, jgarms, philippe_mulet
Version: 3.3   
Target Milestone: 3.3.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 191082    
Attachments:
Description Flags
test case
none
Proposed fix + regression test none

Description Walter Harley CLA 2007-06-14 19:39:31 EDT
The attached test method passes in 3.2.2 but fails in 3.3.  The reason is that in LookupEnvironment we now cache and reuse annotation bindings if the type and values are the same.  The problem with this is that org.eclipse.jdt.core.dom.CompilationUnit.findDeclaringNode() does a reverse lookup of an ASTNode from an IBinding, based on the internal compiler binding contained in the IBinding; so if two ASTNodes share the same internal compiler binding, the wrong ASTNode is returned.  This is causing APT to report incorrect source positions; see bug 191082.
Comment 1 Walter Harley CLA 2007-06-14 19:40:13 EDT
Created attachment 71383 [details]
test case

Attached test case patch
Comment 2 Olivier Thomann CLA 2007-06-15 11:14:24 EDT
I think the mistake was to share the compiler annotation bindings.
In fact we cannot do that because of the reverse mapping that we need to be able to do between DOM binding -> declaring node.
If I revert this, I'll need to fix the apt mirror implementation for annotation since the equals is based on the fact that annotation bindings are identical.
I am working on it.
Both changes need to be done at the same time.
Comment 3 Olivier Thomann CLA 2007-07-05 09:46:45 EDT
Released for 3.3.1.
Regression tests added in org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorDeclarationTestAnnotationProcessor#testClassDeclaration
org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0276
Comment 4 Olivier Thomann CLA 2007-07-05 09:54:48 EDT
Released for 3.4M1.
Same regression tests as for 3.3.1.
Comment 5 Olivier Thomann CLA 2007-07-09 08:40:50 EDT
Created attachment 73309 [details]
Proposed fix + regression test

Philippe,
+1 for 3.3.1?
Comment 6 Olivier Thomann CLA 2007-07-09 08:42:36 EDT
Philippe,

Since the fix is in the compiler, I request the +1 from you. I forgot to ask for it before I released it.
Could you please also add your +1 for bug 191082 since this is exactly the same problem?
Comment 7 Frederic Fusier CLA 2007-08-07 06:20:12 EDT
Code verified for 3.4M1 using build I20070806-1800.
Comment 8 Eric Jodet CLA 2007-09-03 09:44:31 EDT
Code verified for 3.3.1 using build M20070831-2000