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
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateAttacher()The attacher provides onlystaticutility methods and should not be instantiated. -
Method Summary
-
Field Details
-
DUMP_PROPERTY
Indicates that any error during attachment should be dumped to a given file location. When set for external attachment, diagnostic information is appended to this file.- See Also:
-
ARGUMENT_ENVIRONMENT_VARIABLE
The environment variable that supplies the agent argument. The argument is not supplied as a command line argument as the arguments of a process can be read by other users of the same host, for example by reading/proc/[pid]/cmdlineon a Linux host, such that the argument is not exposed to them unnecessarily.- See Also:
-
-
Constructor Details
-
Attacher
private Attacher()The attacher provides onlystaticutility 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 isnullor any number of strings where the first argument is proceeded by any single character which is stripped off. The agent argument is only read from this list if it is not supplied by theARGUMENT_ENVIRONMENT_VARIABLEenvironment variable which is preferred to avoid its exposure on the command line.
-
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-trueif the agent is native.argument- The argument to provide ornullif 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.
-