Package net.bytebuddy.agent
Class Installer
- java.lang.Object
-
- net.bytebuddy.agent.Installer
-
public class Installer extends java.lang.ObjectAn installer class which defined the hook-in methods that are required by the Java agent specification.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.instrument.InstrumentationinstrumentationA field for carrying theInstrumentationthat was loaded by the Byte Buddy agent.static java.lang.StringNAMEThe name of theInstallerclass that is stored in an obfuscated format which will not be relocated.
-
Constructor Summary
Constructors Modifier Constructor Description privateInstaller()The installer provides onlystatichook-in methods and should not be instantiated.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidagentmain(java.lang.String arguments, java.lang.instrument.Instrumentation instrumentation)Allows the installation of this agent via the attach API.private static voiddoMain(java.lang.instrument.Instrumentation instrumentation)Installs theInstrumentationin the current class and possibly obfuscated class.static java.lang.instrument.InstrumentationgetInstrumentation()Returns the instrumentation that was loaded by the Byte Buddy agent.static voidpremain(java.lang.String arguments, java.lang.instrument.Instrumentation instrumentation)Allows the installation of this agent via a command line argument.
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
The name of theInstallerclass that is stored in an obfuscated format which will not be relocated.
-
instrumentation
@MaybeNull private static volatile java.lang.instrument.Instrumentation instrumentation
A field for carrying theInstrumentationthat 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 benulleven after the installation of the Byte Buddy agent as this class might be loaded by a different class loader than the system class loader.
-
-
Method Detail
-
getInstrumentation
public static java.lang.instrument.Instrumentation getInstrumentation()
Returns the instrumentation that was loaded by the Byte Buddy agent. When a security manager is active, the
RuntimePermissionforgetInstrumentationis 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
public static void premain(java.lang.String arguments, java.lang.instrument.Instrumentation instrumentation)Allows the installation of this agent via a command line argument.- Parameters:
arguments- The unused agent arguments.instrumentation- The instrumentation instance.
-
agentmain
public static void agentmain(java.lang.String arguments, java.lang.instrument.Instrumentation instrumentation)Allows the installation of this agent via the attach API.- Parameters:
arguments- The unused agent arguments.instrumentation- The instrumentation instance.
-
doMain
private static void doMain(java.lang.instrument.Instrumentation instrumentation)
Installs theInstrumentationin the current class and possibly obfuscated class.- Parameters:
instrumentation- The instrumentation instance.
-
-