Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Problems (Misunderstandings) With AspectJ 1.1

It looks like the aspectj runtime classes in aspectjrt.jar are not 
visible to classes affected by aspects.  

You might be putting them on the user classpath like this:

  java -classpath "aspectjrt.jar[...]" ...

If weaving system classes (rt.jar, any libraries in ext/), 
try loading them from the boot loader (from which the system
classes are loaded) by appending aspectrt to the bootclasspath:

  java -Xbootclasspath/a:aspectjrt.jar ...

But for an effective experiment, it's probably better to avoid
affecting classes in the boot loader, esp. if they are required to
load the runtime classes (if not to avoid violating any licenses).

Wes

Joey Gibson wrote:
> 
> 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


Back to the top