AspectJ (ajc) compiler against weaving load times

A few questions here:

  • Does ajc change all the classes it compiles (even non-aspect)? What if I combine only the ant aspect classes, then put them in the same class path with the common ones?

  • Is a compiled ajc project running faster than one that uses weaving at boot time?

  • What if I need to write a library that traces using AspectJ, and then I want this library to work with ANY project? In this case, the only option to load in time?

+6
source share
1 answer
  • ajc (compilation time) only modifies the classes affected by the aspects. Remember that ajc is an extension of the Java compiler (more precisely, it is based on the Eclipse 3.3 JDT compiler). Thus, it will compile all your Java classes, just like a regular Java compiler. Then he additionally gossips all the classes that are affected by the aspect. If you compile your aspects separately from your non-aspects, then there will be no compilation time merge, and your aspects will not have any effect. However, you can put your aspects on the aspect path of compiling your non-aspects (if your non-aspects are compiled by ajc). This will allow your non-aspects to be woven according to your aspects.
  • CTW startup time is much better than LTW, but after loading all classes, the speed difference should be negligible. The reason is that under LTW all classes are intertwined when they are loaded. This means that loading classes requires an additional weaving step, which is not required in CTW.
  • Not. As mentioned above, you can add aspects to your path to the aspect of the second project, and then they will be woven at compile time.

More about the path with parameters:

http://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html

+10
source

Source: https://habr.com/ru/post/886247/


All Articles