Community
Participate
Working Groups
I am using AspectJ 1.1rc1. Here is my simple test case... public class Inner1 {} public class Inner2 extends Inner1 {} public interface NewInterface {} public class Outer extends Inner2 implements NewInterface { public static void main(String[] args) { Outer outer = new Outer(); } } public aspect InitAspect { pointcut outerMatch() : initialization(new(..)); before() : outerMatch() { System.out.println(thisJoinPoint.toLongString()); } } As I understand it, the outerMatch() pointcut will match all constructors in the system. The above all compiles nicely but when I run Outer I get the following (please ignore line numbers) ... java.lang.ExceptionInInitializerError: org.aspectj.lang.NoAspectBoundException at InitAspect.aspectOf(InitAspect.java) at InitAspect.<init>(InitAspect.java:14) at InitAspect.ajc$postClinit(InitAspect.java) at InitAspect.<clinit>(InitAspect.java:14) at Inner1.<init>(Inner1.java:14) at Inner2.<init>(Inner2.java:14) at Outer.<init>(Outer.java:14) at Outer.main(Outer.java:18) Exception in thread "main" If I compile the above system with AspectJ 1.0 before running Outer then it all works and I see the following output ... initialization(public Inner1()) initialization(public Inner2()) initialization(public NewInterface()) initialization(public Outer()) It would appear that the pointcut is matching the InitAspect itself. The only way I can get my simple test case to work with 1.1rc1 is to modify my outerMatch() pointcut to explicitly remove the aspect from the scope ... pointcut outerMatch() : initialization(new(..)) && !within(InitAspect); When I run this I get the following output (note the subtle change in the order of the matches compared to what I got using AspectJ 1.0 - now the interface match comes after the Outer match).... initialization(public Inner1()) initialization(public Inner2()) initialization(public Outer()) initialization(public NewInterface()) Is this behaviour a 1.1 bug or was 1.0 behaving incorrectly ?
The NoAspectBoundException is a correct change in AspectJ-1.1 and is documented in the readme: http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/README- 11.html#ASPECT_INSTANTIATION_AND_ADVICE The order of the interface initializers you're seeing is a bug, but I don't believe it is critical, so I'm leaving it as a P3. If it turns out to be easy to fix it should be resolved for 1.1rc2.
A test case has been added to ajcTestsFailing.xml. The 1.2 target milestone has been removed. After analysis, this bug is tightly coupled with the implementation of initialization join points. This implementation is complicated and I'm very wary of changing it to fix a bug this small.
We're not going to get to this in AJ 1.5.0. Marking as "LATER" for consideration in 1.5.1 and future release planning. No-one else has run into this issue that I'm aware of in the 2.5 years since it was first raised so this is not a high-priority problem right now.
LATER/REMIND bugs are being automatically reopened as P5 because the LATER and REMIND resolutions are deprecated.