Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Important aspects of JDK 1.4 weaving

Using JDK1.4 to compile and test aspects using the WeavingURLClassLoader method.
 
When the classes below are compiled together (ajc.bat *.java) and HelloWorld is executed, it works Great! When they are compiled separately (ajc.bat HelloWorld.java, ajc.bat HelloAspect.java) and then HelloWorld is executed, weaving does not occur.  Everything is being done from the same directory, with "." in the classpath, to keep things simple.
 
Any help would be very appreciated.
 
- Bo
 
Here it is! My simple and frustrating example:
 
HelloWorld.java:
import java.io.*;
public class HelloWorld
{
   public void greet(String msg)
   {
      System.out.println(msg);
   }
   public static void main(String args[])
   {
      new HelloWorld().greet("Hello World.");
   }
}
 
HelloAspect.java:
import java.io.*;
public aspect HelloAspect
{
   pointcut GreetCuts(String msg) : call(void *.greet*(String, ..)) && args(msg, ..);
 
   before(String msg) : GreetCuts(msg)
   {
      System.out.println("Before "+msg);
   }
}
 
Aop.xml:
<aspectj>
   <aspects>
      <aspect name="HelloAspect"/>
   </aspects>
   <weaver options="-verbose -XlazyTjp -Xlint:ignore">
      <include within="*" />
   </weaver>
</aspectj>
 

Back to the top