aspectj - Load-time weaving and java -jar -


is possible add aspectj load-time agent when start program -jar ?

with jetty, if start

java -javaagent:aspectjweaver-1.8.0.jar -classpath toto.jar -jar start.jar 

the aspectj not apply. if call

java -javaagent:aspectjweaver-1.8.0.jar -classpath toto.jar;start.jar org.eclipse.jetty.start.main 

all fine.

the problem -jar , ltw seems there different classloading order compared -cp (...) my.mainclass approach. jar specified -jar loaded before weaver can see aspects , meta-inf/aop-ajc.xml in aspect jar on classpath. found workaround, not nice: can put aspect jar on jvm's boot classpath, in case aspects loaded before weaving agent. have add aspectjrt.jar boot classpath:

java -xbootclasspath/a:aspect.jar;lib\aspectjrt.jar -javaagent:lib\aspectjweaver.jar -jar application.jar 

considering circumstance, guess preferable add application jar normal classpath , specify main class manually. matter of taste , whether know main class name when starting application.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -