Subject: how aspectj works... (a correction)
From: Paul Freeman (pfreeman@ccs.neu.edu)
Date: Wed Oct 09 2002 - 08:50:02 EDT
my command line call was not quite correct... so it has been changed. I
have also added a brief addition to the bottom of this email regarding
the use of a ".lst" file to help in the compilation.
**********
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 *.java
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. Rememberto 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
***************
another way to compile:
instead of using a "*.java at the command line, you can pass to the aspectj compiler a list of the files to compile in what aspectj refers to as an arg file. Arg files have the extension ".lst" (that is an L not a number 1). You may need to use a ".lst" file if you are compiling files contained in packages - i.e. you may need to rout the compiler to the appropriate directories.
Here are the contents of a list file named "LoDChecker.lst" that I used to compile part 1 of the second assignment:
src/lodchecker/Foo.java
src/lodchecker/JPUtil.java
src/lodchecker/LoDObjectChecker.java
src/lodchecker/LoDPointcuts.java
The file simply lists each file to be compiled on a separate line. The path to the file is relative from the location of the ".lst" file.
To use a ".lst" file, you need to cd to the location of the file and then type:
ajc -argfile <filename>.lst
so for my argfile above named "LoDChecker.lst", my command would have been:
ajc -argfile LoDChecker.lst
If you use the Eclipse IDE, it will generate ".lst" files for you, making this whole process a bit easier.
Hope this helps,
Paul
This archive was generated by hypermail 2b28 : Wed Oct 09 2002 - 08:52:24 EDT