I'm a little confused how the AspectJ compiler, ajc
works. To my understanding when talking about CTW, ajc is used to weave aspects into the compiled byte-code - ie: the .class file.
However, when I look at the maven-plugin for AspectJ (aspectj-maven-plugin
), it turns out that it is run in the generate-sources
phase of maven, before the javac compiler. Which would imply that the compiler runs after the aspect weaving. That kind of makes sense, since you can weave in ITDs, modifying class members, etc. which the java compiler would need to know about in order to compile any dependent classes.
So if that is the case, and ajc
runs before javac, I presume that ajc
must first compile all the java code into byte code to be able to weave in any aspects.
So the question is, if ajc
already goes through the efforts of compiling all the java code into byte code, why does javac even need to run at all? Why isn't ajc
the only compiler that is required? Isn't having both run just duplicating the efforts? Additionally, how does javac
handle the classes that ajc
has already compiled? Does it just ignore them since there is no change in the source file since the .class file was generated?
ajc can compile all the classes, its built on the eclipse java compiler. ajc is the only compiler that is required to generate classes.
as far as duplicated efforts, javac will most likely not overwrite .class files that have a newer timestamp than the source java file. also you can imagine builds where some of the sources are compiled with ajc, and some with javac.
as far as maven scheduling goes, i dont know.