I am starting to learn AspectJ. From reading tutorials, I know that I can weave aspects into already compiled class files. However, I just cannot figure out the command that allows me to merge a compiled class file with aspects written on an another file. And one more thing, is it mandatory to have the aspects written in a *.aj file? Thank you
+1
A:
You must add the compiled classes to your inpath. The command line arguments are mostly similar to javac, with some additions. Eg-
ajc -inpath library.jar -sourceroots path/to/sources -classpath $CLASSPATH
The inpath flag can take a jar file, a directory, or a path separated list of either. Also, note that the classes on the inpath are re-woven and new class files are produced in the output directory.
More information here: http://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html
As for your second question, yes. Aspects can be in either .aj files or .java files. However, .aj is recommended since these files are recognized by AJDT in the editor. Of course, if you use @Aspect style syntax, you can safely use .java even in eclipse.
Andrew Eisenberg
2010-02-27 03:47:04