public class Agents
extends java.lang.Object
| Constructor and Description |
|---|
Agents() |
| Modifier and Type | Method and Description |
|---|---|
static java.io.File |
createDummyAgent(java.lang.Class<?> agentClass)
Create a temp empty dummy agent jar for a given class
|
static void |
createDummyAgent(java.io.File agentJar,
java.lang.String agentName)
Create an empty dummy agent jar for a given class
|
static java.lang.instrument.Instrumentation |
getInstrumentation()
Get an instrumentation instance by loading an agent
The loaded agent stores the instrumentation instance in a static field which is accessed by reflection This solves many problems which can occur with class loaders |
static void |
load(java.io.File agentJar)
Load an agent from a jar during runtime
|
static void |
loadInternal(java.lang.Class<?> agentClass)
Create a dummy agent jar for the given class and load it
|
public static java.io.File createDummyAgent(java.lang.Class<?> agentClass)
throws java.io.IOException
agentClass - The class to create the agent forjava.io.IOException - If an I/O error occurspublic static void createDummyAgent(java.io.File agentJar,
java.lang.String agentName)
throws java.io.IOException
agentJar - The path to the agent jaragentName - The name of the agent classjava.io.IOException - If an I/O error occurspublic static void load(java.io.File agentJar)
throws java.lang.ClassNotFoundException
agentJar - The path to the agent jarjava.lang.ClassNotFoundException - If the InstrumentationImpl class is not foundpublic static void loadInternal(java.lang.Class<?> agentClass)
throws java.io.IOException,
java.lang.ClassNotFoundException
agentClass - The class to create the agent forjava.io.IOException - If an I/O error occursjava.lang.ClassNotFoundException - If the InstrumentationImpl class is not foundpublic static java.lang.instrument.Instrumentation getInstrumentation()
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOException - If an IO error occursjava.lang.ClassNotFoundException - If the InstrumentationImpl class is not found