Let's say i have an app built from 3 files:
MyApp.java
(application):
public class MyApp {...}
MyAspect.aj
(adds some functionality to the app):
public aspect MyAspect {
before(): execution(* MyApp.*(..)) {
AspectHelper helper = new AspectHelper()
...
}
}
AspectHelper.java
(used ONLY by the aspect)
class AspectHelper {...}
after a compile time weaving i'll have MyApp.class
, MyAspect.class
, AspectHelper.class
. when i run the app, do i need all 3 files on the classpath or some of them will be built in the MyApp.class
bytecode and i don't need them as a separate files anymore?
Your weaved classes (MyApp
) will reference the aspect class (MyAspect
). The code you wrote in your aspect class will reference your helper class (AspectHelper
). You will need all files. And of course, the aspectj runtime too. You can check the compiled code with a decompiler tool or with javap
. Try with javap -p -c -s MyApp.class
on your compiled classes directory.