Community
Participate
Working Groups
If I have multiple annotation mirrors that looks exactly the same, the AnnotationMirror.getPosition() just returns the position of one of them. (Usually the last one.) For example in the following Java file: package myTests; import javax.interceptor.AroundInvoke; import javax.interceptor.InvocationContext; public class TestMultipleAroundInvoke { @AroundInvoke() public Object foo(InvocationContext ic) throws Exception { return null; } @AroundInvoke() public Object foo2(InvocationContext ic) throws Exception { return null; } @AroundInvoke() public Object foo3(InvocationContext ic) throws Exception { return null; } } Collection<AnnotationMirror> mirrors = decl.getAnnotationMirrors(); for (AnnotationMirror mirror : mirrors) { System.out.println("[" + declaration + ", " + mirror + "@" + mirror.getPosition);() + "]" } will produce output like: [Object foo(InvocationContext ic), @AroundInvoke()@offset = 326 line = 13 column = 1 length = 12] [Object foo2(InvocationContext ic), @AroundInvoke()@offset = 326 line = 13 column = 1 length = 12] [Object foo3(InvocationContext ic), @AroundInvoke()@offset = 326 line = 13 column = 1 length = 12] Thanks.
I am able to reproduce this. The position returned by the annotated declaration is correct, but the position returned by the annotation mirror itself is not. Am investigating.
This looks like a JDT Core 3.3 regression. In 3.3, cacheing and reuse of compiler internal annotation bindings was introduced (changes introduced in LookupEnvironment version 1.82 and 1.83), but DefaultBindingResolver.getAnnotationInstance() is supposed to be able to translate from a compiler internal annotation binding to a DOM IAnnotationBinding. Reuse means there is not a 1:1 relationship any more so this translation is broken. I will spawn a JDT Core bug for this, and leave this bug open to create a test case for APT.
This is indeed broken. We need to either not have unique compiler annotation bindings or change the binding resolver to be able to retrieve the right ast node when an annotation binding is found. I am investigating. Sounds like a must have for 3.3.1.
I agree with both the analysis and the prioritization. Thanks, Olivier.
Created attachment 73056 [details] Regression tests
Set target as 3.3.1 since this is related to bug 192774 which is targetted for 3.3.1.
Released for 3.3.1. Same regression tests as bug 192774.
Released for 3.4M1. Same regression tests as branch 3.3.1.