Community
Participate
Working Groups
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.
Created attachment 71383 [details] test case Attached test case patch
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.
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
Released for 3.4M1. Same regression tests as for 3.3.1.
Created attachment 73309 [details] Proposed fix + regression test Philippe, +1 for 3.3.1?
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?
Code verified for 3.4M1 using build I20070806-1800.
Code verified for 3.3.1 using build M20070831-2000