[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] Problems (Misunderstandings) With AspectJ 1.1
|
The problem is that your aspect is advising its own static initializer, and until that staticinitializer has run there is no legal aspect -- which is why you get the NoAspectBoundException.
You should modify your pointcut not to include the aspect's static initializer, i.e.
pointcut stat_init(): staticinitialization(!MyAspect+);
Wes is right when he suggests that advising ALL static initializers is unlikely to be what you really want. A likelier form is:
pointcut stat_init(): staticinitialization(my.package..*);
-Jim
> -----Original Message-----
> From: Joey Gibson [mailto:joey@xxxxxxxxxxxxxx]
> Sent: Thursday, April 10, 2003 10:24 AM
> To: aspectj-users@xxxxxxxxxxx
> Subject: [aspectj-users] Problems (Misunderstandings) With AspectJ 1.1
>
> I've got the latest version of AspectJ 1.1 and am trying to test out the
> byte-code weaving. I've got a pointcut that looks like this
>
> pointcut stat_init(): staticinitialization(A+);
>
> and advice
>
> before(): stat_init()
> {
> System.out.println("StaticInit: " + thisJoinPoint);
> }
>
> which works fine for my A class and its subclass, C. But if I change it to
> this
>
> pointcut stat_init(): staticinitialization(java.lang.Object+);
>
> to show me all classes as they are loaded, I get varying degrees of
> failure, depending on how I run it. If I run from within Eclipse, I get
> this
>
> java.lang.ExceptionInInitializerError:
> org.aspectj.lang.NoAspectBoundException
> at com.joeygibson.ajt.Showcase.aspectOf(Showcase.java)
> at com.joeygibson.ajt.Showcase.<clinit>(Showcase.java)
> at com.joeygibson.ajt.A.<clinit>(A.java)
> Exception in thread "main"
>
> If I run from within Ant, I get this
>
> [java] java.lang.NoClassDefFoundError
>
> but changing back to the original pointcut works fine in both
> environments.
> In my Ant build file, I've tried adding injars="c:\jdk1.3\jre\lib\rt.jar"
> to the iajc line, and while I do get a much larger output jar, the result
> is still the same, a NoClassDefFoundError.
>
> Am I doing something wrong? Can anyone help me out? Admittedly, tracing
> all
> static initializers is not terribly useful, it's just an example to see if
> I understand the byte-code weaving stuff.
>
> Thanks,
> Joey
>
>
> --
> http://www.joeygibson.com
> http://www.joeygibson.com/cgi-bin/blosxom.cgi/life/Wisdom.html
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users