I have yet asked the
question, and I made a try.
JDK 1.6 brings Sun Api to
dynamically load java Agent http://java.sun.com/javase/6/docs/technotes/guides/attach/index.html
I test it with aspectjweaver.jar
( in fact a custom myaspectjweaver.jar that contains aspectjweaver.jar ) but I can’t
success a run.
Does-it possible to
attach LTW agent, when an application is already running?
Or the LTW agent *must* be loaded at starting?
I see that there is
some thing similar with the Equinox/Aspects; project in status incubator…
I load the Agent but the
initialisation failed as shown with this traces:
E:\opt\perfStats\scripts>"C:\Program
Files\Java\jdk1.6.0_11\bin\java" -classpath
..\lib\myaspectjweaver.jar;"C:\Program
Files\Java\jdk1.6.0_11\lib\tools.jar";
;. attachapi.launcher.PerfStatsLaunch
4668 E:\opt\perfStats\lib\myaspectjweaver.jar
loading agent :
E:\opt\perfStats\lib\myaspectjweaver.jar
Echec Attach
com.sun.tools.attach.AgentInitializationException:
Agent JAR loaded but agent failed to initialize
at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:103)
at attachapi.launcher.PerfStatsLaunch.attachPerfStats(PerfStatsLaunch.java:33)
at attachapi.launcher.PerfStatsLaunch.main(PerfStatsLaunch.java:69)
My MANIFEST.MF
Manifest-Version: 1.0
Name: org/aspectj/weaver/
Specification-Title:
AspectJ Weaver Classes
Specification-Version:
DEVELOPMENT
Specification-Vendor:
aspectj.org
Implementation-Title:
org.aspectj.weaver
Implementation-Version:
DEVELOPMENT
Implementation-Vendor:
aspectj.org
Premain-Class: org.aspectj.weaver.loadtime.Agent
Can-Redefine-Classes:
true
Agent-Class: org.aspectj.weaver.loadtime.Agent
I added the Agent-Class
line.
Cordialement / Best regards
Jean-Louis
Pasturel