问题描述
我希望在不停止应用程序的情况下分析Java应用程序。我可以在应用程序运行时以某种方式添加Javaagent吗?
I wish to profile a Java application without stopping the application. Can I add a Javaagent somehow while the application is running?
推荐答案
应该可以根据包。
实现可以提供一种机制,以便在VM启动后的某个时间启动代理
。
详细说明了如何启动
是特定于实现的但是
通常应用程序已经启动
并且其主方法已经调用了
。如果
一个实现支持
启动代理后VM已启动
,则适用以下条件:
An implementation may provide a mechanism to start agents sometime after the the VM has started. The details as to how this is initiated are implementation specific but typically the application has already started and its main method has already been invoked. In cases where an implementation supports the starting of agents after the VM has started the following applies:
1.清单代理JAR必须包含属性
Agent-Class。此
属性的值是代理
类的名称。
2.代理类必须实现公共静态代理程序
方法。
3.系统类加载器(ClassLoader.getSystemClassLoader)必须
支持将代理
JAR文件添加到系统类路径的机制。
1.The manifest of the agent JAR must contain the attribute Agent-Class. The value of this attribute is the name of the agent class.
2. The agent class must implement a public static agentmain method.
3. The system class loader ( ClassLoader.getSystemClassLoader) must support a mechanism to add an agent JAR file to the system class path.
但我从未尝试过: - |
这篇关于如何在不停止JVM的情况下将Javaagent添加到JVM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!