public class Attacher
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ATTACH_METHOD_NAME
The name of the
attach method of the VirtualMachine class. |
private static java.lang.String |
DETACH_METHOD_NAME
The name of the
detach method of the VirtualMachine class. |
private static java.lang.String |
LOAD_AGENT_METHOD_NAME
The name of the
loadAgent method of the VirtualMachine class. |
private static java.lang.Object |
STATIC_MEMBER
Base for access to a reflective member to make the code more readable.
|
Modifier | Constructor and Description |
---|---|
private |
Attacher()
The attacher provides only
static utility methods and should not be instantiated. |
Modifier and Type | Method and Description |
---|---|
protected static void |
install(java.lang.Class<?> virtualMachineType,
java.lang.String processId,
java.lang.String agent,
java.lang.String argument)
Installs a Java agent on a target VM.
|
static void |
main(java.lang.String[] args)
Runs the attacher as a Java application.
|
private static final java.lang.Object STATIC_MEMBER
private static final java.lang.String ATTACH_METHOD_NAME
attach
method of the VirtualMachine
class.private static final java.lang.String LOAD_AGENT_METHOD_NAME
loadAgent
method of the VirtualMachine
class.private static final java.lang.String DETACH_METHOD_NAME
detach
method of the VirtualMachine
class.private Attacher()
static
utility methods and should not be instantiated.public static void main(java.lang.String[] args)
args
- A list containing the fully qualified name of the virtual machine type,
the process id, the fully qualified name of the Java agent jar followed by
an empty string if the argument to the agent is null
or any number
of strings where the first argument is proceeded by any single character
which is stripped off.protected static void install(java.lang.Class<?> virtualMachineType, java.lang.String processId, java.lang.String agent, java.lang.String argument) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
virtualMachineType
- The virtual machine type to use for the external attachment.processId
- The id of the process being target of the external attachment.agent
- The Java agent to attach.argument
- The argument to provide or null
if no argument is provided.java.lang.NoSuchMethodException
- If the virtual machine type does not define an expected method.java.lang.reflect.InvocationTargetException
- If the virtual machine type raises an error.java.lang.IllegalAccessException
- If a method of the virtual machine type cannot be accessed.