The Byte Buddy agent provides a JVM java. in order to allow Byte Buddy the
redefinition of already loaded classes. An agent must normally be specified via the command line via the
javaagent parameter. As an argument to this parameter, one must specify the location of this agent's jar
file such as for example in
java -javaagent:byte-buddy-agent.jar -jar app.jar
Note
The runtime installation of a Java agent is not possible on all JVMs. See the documentation for
ByteBuddyAgent#install() for details on JVMs that are supported out of the box.
Important Note
This class's name is known to the Byte Buddy main application and must not be altered.
Note
Byte Buddy does not execute code using an java.security.AccessController. If a security manager
is present, the user of this class is responsible for assuring any required privileges. To read an
Instrumentation, the net.bytebuddy.agent.getInstrumentation runtime permission is required.
| Modifier and Type | Class and Description |
|---|---|
| protected static interface | ByteBuddyAgent.AgentProvider
An agent provider is responsible for handling and providing the jar file of an agent that is being attached. |
| public static interface | ByteBuddyAgent.AttachmentProvider
An attachment provider is responsible for making the Java attachment API available. |
| protected static interface | ByteBuddyAgent.AttachmentTypeEvaluator
An attachment evaluator is responsible for deciding if an agent can be attached from the current process. |
| public static interface | ByteBuddyAgent.ProcessProvider
A process provider is responsible for providing the process id of the current VM. |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | AGENT_ARGUMENT_SEPARATOR
The character that is used to mark the beginning of the argument to the agent. |
| private static final String | AGENT_CLASS_PROPERTY
The manifest property specifying the agent class. |
| private static final String | ATTACHER_FILE_NAME
The naming prefix of all artifacts for an attacher jar. |
| private static final ByteBuddyAgent. | ATTACHMENT_TYPE_EVALUATOR
The attachment type evaluator to be used for determining if an attachment requires an external process. |
| private static final ClassLoader | BOOTSTRAP_CLASS_LOADER
Representation of the bootstrap |
| private static final int | BUFFER_SIZE
The size of the buffer for copying the agent installer file into another jar. |
| private static final String | CAN_REDEFINE_CLASSES_PROPERTY
The manifest property specifying the can redefine property. |
| private static final String | CAN_RETRANSFORM_CLASSES_PROPERTY
The manifest property specifying the can retransform property. |
| private static final String | CAN_SET_NATIVE_METHOD_PREFIX
The manifest property specifying the can set native method prefix property. |
| private static final File | CANNOT_SELF_RESOLVE
Represents a failed attempt to self-resolve a jar file location. |
| private static final String | CLASS_FILE_EXTENSION
The file extension for a class file. |
| private static final String | CLASS_PATH_ARGUMENT
The class path argument to specify the class path elements. |
| private static final int | END_OF_FILE
Convenience indices for reading and writing to the buffer to make the code more readable. |
| private static final String | FILE_PROTOCOL
Represents the |
| private static final String | INSTRUMENTATION_METHOD
The name of the method for reading the installer's instrumentation. |
| private static final String | JAR_FILE_EXTENSION
The file extension for a jar file. |
| private static final String | JAVA_HOME
The Java property denoting the Java home directory. |
| public static final String | LATENT_RESOLVE
Indicates that the agent should not resolve its own code location for a self-attachment. |
| private static final String | MANIFEST_VERSION_VALUE
The manifest property value for the manifest version. |
| private static final String | OS_NAME
The Java property denoting the operating system name. |
| private static final int | START_INDEX
Convenience indices for reading and writing to the buffer to make the code more readable. |
| private static final int | SUCCESSFUL_ATTACH
The status code expected as a result of a successful attachment. |
| private static final Instrumentation | UNAVAILABLE
An indicator variable to express that no instrumentation is available. |
| private static final String | WITHOUT_ARGUMENT
Represents a no-op argument for a dynamic agent attachment. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static void | |
| public static void | |
| public static void | attach(File
The agent jar file. agentJar, String The target process id. processId, ByteBuddyAgent.The attachment provider to use. attachmentProviderAttaches the given agent Jar on the target process which must be a virtual machine process. |
| public static void | attach(File
The agent jar file. agentJar, String The target process id. processId, String The argument to provide to the agent. argument, ByteBuddyAgent.The attachment provider to use. attachmentProviderAttaches the given agent Jar on the target process which must be a virtual machine process. |
| public static void | attach(File
The agent jar file. agentJar, ByteBuddyAgent.A provider of the target process id. processProviderAttaches the given agent Jar on the target process which must be a virtual machine process. |
| public static void | attach(File
The agent jar file. agentJar, ByteBuddyAgent.A provider of the target process id. processProvider,The argument to provide to the agent. argument)Attaches the given agent Jar on the target process which must be a virtual machine process. |
| public static void | attach(File
The agent jar file. agentJar, ByteBuddyAgent.A provider of the target process id. processProvider,The attachment provider to use. attachmentProviderAttaches the given agent Jar on the target process which must be a virtual machine process. |
| public static void | attach(File
The agent jar file. agentJar, ByteBuddyAgent.A provider of the target process id. processProvider,The argument to provide to the agent. argument, ByteBuddyAgent.The attachment provider to use. attachmentProviderAttaches the given agent Jar on the target process which must be a virtual machine process. |
| public static void | attachNative(File
The agent jar file. agentLibrary, String The target process id. processId)Attaches the given agent library on the target process which must be a virtual machine process. |
| public static void | attachNative(File
The agent library. agentLibrary, String The target process id. processId, String The argument to provide to the agent. argument)Attaches the given agent library on the target process which must be a virtual machine process. |
| public static void | attachNative(File
The agent library. agentLibrary, String The target process id. processId, ByteBuddyAgent.The attachment provider to use. attachmentProviderAttaches the given agent library on the target process which must be a virtual machine process. |
| public static void | attachNative(File
The agent library. agentLibrary, String The target process id. processId, String The argument to provide to the agent. argument, ByteBuddyAgent.The attachment provider to use. attachmentProviderAttaches the given agent library on the target process which must be a virtual machine process. |
| public static void | attachNative(File
The agent library. agentLibrary, ByteBuddyAgent.A provider of the target process id. processProviderAttaches the given agent library on the target process which must be a virtual machine process. |
| public static void | attachNative(File
The agent library. agentLibrary, ByteBuddyAgent.A provider of the target process id. processProvider,The argument to provide to the agent. argument)Attaches the given agent library on the target process which must be a virtual machine process. |
| public static void | attachNative(File
The agent library. agentLibrary, ByteBuddyAgent.A provider of the target process id. processProvider,The attachment provider to use. attachmentProviderAttaches the given agent library on the target process which must be a virtual machine process. |
| public static void | attachNative(File
The agent library. agentLibrary, ByteBuddyAgent.A provider of the target process id. processProvider,The argument to provide to the agent. argument, ByteBuddyAgent.The attachment provider to use. attachmentProviderAttaches the given agent library on the target process which must be a virtual machine process. |
| private static Instrumentation | Returns: The Byte Buddy agent'sjava. instance.Performs the actual lookup of the |
| private static < The type of the action's resolved value. T> T | Returns: The action's resolved value.The action to execute from a privileged context. action)A proxy for |
| public static Instrumentation | Returns: Thejava. instance which is provided by an installed
Byte Buddy agent.
Looks up the |
| public static Instrumentation | Returns: An instrumentation instance representing the currently running JVM.Installs an agent on the currently running Java virtual machine. |
| public static Instrumentation | Returns: An instrumentation instance representing the currently running JVM.The attachment provider to use for the installation. attachmentProviderInstalls an agent on the currently running Java virtual machine using the supplied attachment provider. |
| public static Instrumentation | Returns: An instrumentation instance representing the currently running JVM.The provider for the current JVM's process id. processProviderInstalls an agent on the Java virtual machine resolved by the process provider. |
| public static synchronized Instrumentation | Returns: An instrumentation instance representing the currently running JVM.The attachment provider to use for the installation. attachmentProvider,The provider for the current JVM's process id. processProviderInstalls an agent on the currently running Java virtual machine using the supplied attachment provider and process provider. |
| private static void | install(ByteBuddyAgent.
The attachment provider to use. attachmentProvider,The process id of the target JVM process. processId, String The argument to provide to the agent. argument, ByteBuddyAgent.The agent provider for the agent jar or library. agentProvider,true if the agent is native.Installs a Java agent on a target VM. |
| private static void | installExternal(ByteBuddyAgent.
A description of the external attachment. externalAttachment,The process id of the current process. processId, File The Java agent to install. agent, boolean true if the agent is native.The argument to provide to the agent or argument)null if no argument should be supplied.Installs a Java agent to the current VM via an external process. |
| private static File | Returns: The self-resolved jar file ornull if the jar file cannot be located.Attempts to resolve the location of the |