I just start learning
JVM TI
. About the java command: java -agentpath:../tool.dll javaClass, I know that there is aAgent_OnLoad()
method indll
and maybe it set some eventcallback method
. And I know the jvm executeAgent_OnLoad()
first and then executejavaClass
.And theAgent_OnUnLoad()
is also called by jvm.
Then the problem comes, how the jvm know when call Agent_OnUnLoad() method
. At First, I think that after javaClass
is executed jvm will calls Agent_OnUnload()
, but then I discard this thought because at this time, maybe the dll
is doing sth e.g. writing data to disk.
So how jvm know it is the right time to call Agent_OnUnLoad() method?
There is no standard mechanism defined to unload agent libraries. Agent_OnUnload
will be called only before the VM termination, when all Shutdown hooks are completed.