Package net.bytebuddy.agent
Class Attacher
java.lang.Object
net.bytebuddy.agent.Attacher
A Java program that attaches a Java agent to an external process.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The name of theattach
method of theVirtualMachine
class.private static final String
The name of thedetach
method of theVirtualMachine
class.private static final String
The name of theloadAgent
method of theVirtualMachine
class.private static final String
The name of theloadAgentPath
method of theVirtualMachine
class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Attacher()
The attacher provides onlystatic
utility methods and should not be instantiated. -
Method Summary
-
Field Details
-
ATTACH_METHOD_NAME
The name of theattach
method of theVirtualMachine
class.- See Also:
-
LOAD_AGENT_METHOD_NAME
The name of theloadAgent
method of theVirtualMachine
class.- See Also:
-
LOAD_AGENT_PATH_METHOD_NAME
The name of theloadAgentPath
method of theVirtualMachine
class.- See Also:
-
DETACH_METHOD_NAME
The name of thedetach
method of theVirtualMachine
class.- See Also:
-
-
Constructor Details
-
Attacher
private Attacher()The attacher provides onlystatic
utility methods and should not be instantiated.
-
-
Method Details
-
main
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 isnull
or any number of strings where the first argument is proceeded by any single character which is stripped off.
-
install
protected static void install(Class<?> virtualMachineType, String processId, String agent, boolean isNative, @MaybeNull String argument) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException Installs 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
-true
if the agent is native.argument
- The argument to provide ornull
if no argument is provided.- Throws:
NoSuchMethodException
- If the virtual machine type does not define an expected method.InvocationTargetException
- If the virtual machine type raises an error.IllegalAccessException
- If a method of the virtual machine type cannot be accessed.
-