当执行关于“java -agentpath:c:/tool.dll javaClass 的 Agent_UnLoad() 方法时

when execute Agent_UnLoad() method about "java -agentpath:c:/tool.dll javaClass

I just start learning JVM TI. About the java command: java -agentpath:../tool.dll javaClass, I know that there is a Agent_OnLoad() method in dll and maybe it set some event callback method. And I know the jvm execute Agent_OnLoad() first and then execute javaClass.And the Agent_OnUnLoad() is also called by jvm.


那么问题来了,jvm 是怎么知道什么时候调用的Agent_OnUnLoad() method 。起初,我认为在 javaClass 执行后 jvm 将调用 Agent_OnUnload(),但后来我放弃了这个想法,因为此时,也许 dll 正在做某事,例如将数据写入磁盘。


So how jvm know it is the right time to call Agent_OnUnLoad() method?

没有定义卸载代理库的标准机制。 Agent_OnUnload 只会在 VM 终止之前调用,当所有 Shutdown 挂钩完成时。