Community
Participate
Working Groups
There is a problem when the @annotation is used in a context where the annotation for the method is not declared neither in the type of the object instance nor in its super type. The following example shows the problem I have detected. The compiler throws the following exception: java.lang.IllegalStateException at org.aspectj.weaver.bcel.BcelShadow.getAnnotations(BcelShadow.java:1578) at org.aspectj.weaver.bcel.BcelShadow.initializeKindedAnnotationVars(BcelShadow.java:1603) at org.aspectj.weaver.bcel.BcelShadow.getKindedAnnotationVar(BcelShadow.java:1087) at org.aspectj.weaver.patterns.AnnotationPointcut.findResidueInternal(AnnotationPointcut.java:195) at org.aspectj.weaver.patterns.Pointcut.findResidue(Pointcut.java ... lasses when weaving when batch building BuildConfig[/home/pacz/workspace/.metadata/.plugins/org.eclipse.ajdt.core/MyBugTest.generated.lst] #Files=7 The example: public class A { @MyAnnotation public void foo() { } } public class B extends A { } public class C extends B { } public class Test { public static void main(String args[]) { C c = new C(); c.foo(); } } public aspect MyAspect { // this throws an exception before(MyAnnotation myAnnotation) : call(@MyAnnotation * *..*.*(..)) && @annotation(myAnnotation) { } // this, however, works fine // before() : // call(@MyAnnotation * *..*.*(..)) { // // } }
you didn't include the declaration of the annotation type - but i made one up. The bug here is that the hierarchy is more than 2 deep. You have A > B > C. If you have A > C (ie. C extends A directly) then it would work without an error. I've committed a testcase and the fix - thanks for supplying a minimal set of files that show the problem.
fix available in latest dev build.