public class AgentLoader extends Object
Instrumentation| Constructor and Description |
|---|
AgentLoader() |
| Modifier and Type | Method and Description |
|---|---|
static void |
createAgentJar(OutputStream out,
String agentClass,
String bootClassPath,
boolean canRedefineClasses,
boolean canRetransformClasses,
boolean canSetNativeMethodPrefix)
Creates an agent jar with the proper manifest file to start a javaagent.
|
static File |
createTemporaryAgentJar(String agentClass,
String bootClassPath,
boolean canRedefineClasses,
boolean canRetransformClasses,
boolean canSetNativeMethodPrefix)
Creates a jar in runtime with the proper manifest file to start the javaagent.
|
static String |
getPid()
Gets the current jvm's pid.
|
static void |
loadAgent(String agentJar,
String options)
Dynamically loads a java agent.
|
static void |
loadAgentClass(String agentClassName,
String options)
Creates loads the agent class directly.
|
static void |
loadAgentClass(String agentClass,
String options,
String bootClassPath,
boolean canRedefineClasses,
boolean canRetransformClasses,
boolean canSetNativeMethodPrefix)
Creates loads the agent class directly.
|
public static void loadAgent(String agentJar, String options)
agentJar - the agent jaroptions - options that will be passed back to the agent, can be nullInstrumentationpublic static void loadAgentClass(String agentClassName, String options)
if(MyAgent.class.getClassLoader() != ClassLoader.getSystemClassLoader()) {
ClassPathUtils.appendToSystemPath(ClassPathUtils.getClassPathFor(MyAgent.class));
ClassPathUtils.appendToSystemPath(ClassPathUtils.getClassPathFor(OtherDepenencies.class));
}
loadAgent(MyAgent.class.getName(), null, null, true, true, false);
agentClassName - the agent class nameoptions - options that will be passed back to the agent, can be nullpublic static void loadAgentClass(String agentClass, String options, String bootClassPath, boolean canRedefineClasses, boolean canRetransformClasses, boolean canSetNativeMethodPrefix)
if(MyAgent.class.getClassLoader() != ClassLoader.getSystemClassLoader()) {
ClassPathUtils.appendToSystemPath(ClassPathUtils.getClassPathFor(MyAgent.class));
ClassPathUtils.appendToSystemPath(ClassPathUtils.getClassPathFor(OtherDepenencies.class));
}
loadAgent(MyAgent.class.getName(), null, null, true, true, false);
agentClass - the agent classoptions - options that will be passed back to the agent, can be nullbootClassPath - list of jars to be loaded with the agent, can be nullcanRedefineClasses - if the ability to redefine classes is need by the agent, suggested default: falsecanRetransformClasses - if the ability to retransform classes is need by the agent, suggested default: falsecanSetNativeMethodPrefix - if the ability to set native method prefix is need by the agent, suggested default: falseClassPathUtils,
Instrumentationpublic static String getPid()
public static File createTemporaryAgentJar(String agentClass, String bootClassPath, boolean canRedefineClasses, boolean canRetransformClasses, boolean canSetNativeMethodPrefix) throws IOException
agentClass - the agent classbootClassPath - list of jars to be loaded with the agent, can be nullcanRedefineClasses - if the ability to redefine classes is need by the agent, suggested default: falsecanRetransformClasses - if the ability to retransform classes is need by the agent, suggested default: falsecanSetNativeMethodPrefix - if the ability to set native method prefix is need by the agent, suggested default: falseIOExceptionpublic static void createAgentJar(OutputStream out, String agentClass, String bootClassPath, boolean canRedefineClasses, boolean canRetransformClasses, boolean canSetNativeMethodPrefix) throws IOException
agentClass - the agent classbootClassPath - list of jars to be loaded with the agent, can be nullcanRedefineClasses - if the ability to redefine classes is need by the agent, suggested default: falsecanRetransformClasses - if the ability to retransform classes is need by the agent, suggested default: falsecanSetNativeMethodPrefix - if the ability to set native method prefix is need by the agent, suggested default: falseIOExceptionCopyright © 2017 Electronic Arts Inc. All rights reserved.