how aspectj works...


Subject: how aspectj works...
From: Paul Freeman (pfreeman@ccs.neu.edu)
Date: Wed Oct 09 2002 - 08:20:40 EDT


Hi Class -

I have received a number of questions regarding how to run the program
with AspectJ after you have compiled it with the AspectJ compiler (ajc).
 In short, you just run the program as you normally would. The ajc has
already done merged your aspectj code with the java code to create a
working program.

The long of it:

The AspectJ compiler actually takes your Aspect files, interprets the
code you have written there - composing Java code that will carry out
the appropriate actions, and "weaves" (i.e. inserts) the Java code it
created into your existing Java files - actually producing new
(temporary) Java files. Then it runs the standard Java compiler to
produce your class files and deletes the temporary java files. If you
want, you can see the temporary Java files produced by adding the
argument "-preprocess" to your command line call of ajc, i.e.
ajc -preprocess Foo

Using preprocess will not activate the java compiler and will therefore
not create your class files. It will leave all of the temporary Java
files in a temporary directory called "ajworkingdir". By looking at the
Java files there, you can see the code AspectJ "weaves" into your Java
files.

I hope this helps clear up what is actually going on when you use AspectJ.

Remeber to check out the Eclipse IDE when you have a chance. You may
find it easier to write and compile your code once you get used to using
the IDE.

Paul



This archive was generated by hypermail 2b28 : Wed Oct 09 2002 - 08:23:02 EDT