Package net.bytebuddy.agent
Class Installer
java.lang.Object
net.bytebuddy.agent.Installer
An installer class which defined the hook-in methods that are required by the Java agent specification.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Instrumentation
A field for carrying theInstrumentation
that was loaded by the Byte Buddy agent. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
The installer provides onlystatic
hook-in methods and should not be instantiated. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
agentmain
(String arguments, Instrumentation instrumentation) Allows the installation of this agent via the Attach API.static Instrumentation
Returns the instrumentation that was loaded by the Byte Buddy agent.static void
premain
(String arguments, Instrumentation instrumentation) Allows the installation of this agent via a command line argument.
-
Field Details
-
instrumentation
A field for carrying theInstrumentation
that was loaded by the Byte Buddy agent. Note that this field must never be accessed directly as the agent is injected into the VM's system class loader. This way, the field of this class might benull
even after the installation of the Byte Buddy agent as this class might be loaded by a different class loader than the system class loader.
-
-
Constructor Details
-
Installer
private Installer()The installer provides onlystatic
hook-in methods and should not be instantiated.
-
-
Method Details
-
getInstrumentation
Returns the instrumentation that was loaded by the Byte Buddy agent. When a security manager is active, the
RuntimePermission
forgetInstrumentation
is required by the caller.Important: This method must only be invoked via the
ClassLoader.getSystemClassLoader()
where any Java agent is loaded. It is possible that two versions of this class exist for different class loaders.- Returns:
- The instrumentation instance of the Byte Buddy agent.
-
premain
Allows the installation of this agent via a command line argument.- Parameters:
arguments
- The unused agent arguments.instrumentation
- The instrumentation instance.
-
agentmain
Allows the installation of this agent via the Attach API.- Parameters:
arguments
- The unused agent arguments.instrumentation
- The instrumentation instance.
-