Package net.bytebuddy.agent
Class Attacher
- java.lang.Object
-
- net.bytebuddy.agent.Attacher
-
public class Attacher extends java.lang.ObjectA Java program that attaches a Java agent to an external process.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringATTACH_METHOD_NAMEThe name of theattachmethod of theVirtualMachineclass.private static java.lang.StringDETACH_METHOD_NAMEThe name of thedetachmethod of theVirtualMachineclass.private static java.lang.StringLOAD_AGENT_METHOD_NAMEThe name of theloadAgentmethod of theVirtualMachineclass.private static java.lang.StringLOAD_AGENT_PATH_METHOD_NAMEThe name of theloadAgentPathmethod of theVirtualMachineclass.private static java.lang.ObjectSTATIC_MEMBERBase for access to a reflective member to make the code more readable.
-
Constructor Summary
Constructors Modifier Constructor Description privateAttacher()The attacher provides onlystaticutility methods and should not be instantiated.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static voidinstall(java.lang.Class<?> virtualMachineType, java.lang.String processId, java.lang.String agent, boolean isNative, java.lang.String argument)Installs a Java agent on a target VM.static voidmain(java.lang.String[] args)Runs the attacher as a Java application.
-
-
-
Field Detail
-
STATIC_MEMBER
private static final java.lang.Object STATIC_MEMBER
Base for access to a reflective member to make the code more readable.
-
ATTACH_METHOD_NAME
private static final java.lang.String ATTACH_METHOD_NAME
The name of theattachmethod of theVirtualMachineclass.- See Also:
- Constant Field Values
-
LOAD_AGENT_METHOD_NAME
private static final java.lang.String LOAD_AGENT_METHOD_NAME
The name of theloadAgentmethod of theVirtualMachineclass.- See Also:
- Constant Field Values
-
LOAD_AGENT_PATH_METHOD_NAME
private static final java.lang.String LOAD_AGENT_PATH_METHOD_NAME
The name of theloadAgentPathmethod of theVirtualMachineclass.- See Also:
- Constant Field Values
-
DETACH_METHOD_NAME
private static final java.lang.String DETACH_METHOD_NAME
The name of thedetachmethod of theVirtualMachineclass.- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Runs the attacher as a Java application.- Parameters:
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 isnullor any number of strings where the first argument is proceeded by any single character which is stripped off.
-
install
protected static void install(java.lang.Class<?> virtualMachineType, java.lang.String processId, java.lang.String agent, boolean isNative, java.lang.String argument) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessExceptionInstalls a Java agent on a target VM.- Parameters:
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.isNative-trueif the agent is native.argument- The argument to provide ornullif no argument is provided.- Throws:
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.
-
-