@HashCodeAndEqualsPlugin.Enhance public static class ClassInjector.UsingUnsafe extends ClassInjector.AbstractBase
A class injector that uses sun.misc.Unsafe to inject classes.
Important: This strategy is no longer available after Java 11.
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
ClassInjector.UsingUnsafe.Dispatcher
A dispatcher for using
sun.misc.Unsafe. |
ClassInjector.AbstractBase, ClassInjector.UsingInstrumentation, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe| Modifier and Type | Field and Description |
|---|---|
private static java.lang.Object |
BOOTSTRAP_LOADER_LOCK
A lock for the bootstrap loader when injecting code.
|
private java.lang.ClassLoader |
classLoader
The class loader to inject classes into or
null for the bootstrap loader. |
private static ClassInjector.UsingUnsafe.Dispatcher.Initializable |
DISPATCHER
The dispatcher to use.
|
private java.security.ProtectionDomain |
protectionDomain
The protection domain to use or
null for no protection domain. |
static java.lang.String |
SAFE_PROPERTY
If this property is set, Byte Buddy does not make use of any
Unsafe class. |
ALLOW_EXISTING_TYPES, SUPPRESS_ACCESS_CHECKS| Constructor and Description |
|---|
UsingUnsafe(java.lang.ClassLoader classLoader)
Creates a new unsafe injector for the given class loader with a default protection domain.
|
UsingUnsafe(java.lang.ClassLoader classLoader,
java.security.ProtectionDomain protectionDomain)
Creates a new unsafe injector for the given class loader with a default protection domain.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.Class<?>> |
injectRaw(java.util.Map<? extends java.lang.String,byte[]> types)
Injects the given types into the represented class loader using a mapping from name to binary representation.
|
boolean |
isAlive()
Indicates if this class injector is available on the current VM.
|
static boolean |
isAvailable()
Checks if unsafe class injection is available on the current VM.
|
static ClassInjector |
ofBootLoader()
Returns an unsafe class injector for the boot class loader.
|
static ClassInjector |
ofPlatformLoader()
Returns an unsafe class injector for the platform class loader.
|
static ClassInjector |
ofSystemLoader()
Returns an unsafe class injector for the system class loader.
|
injectpublic static final java.lang.String SAFE_PROPERTY
Unsafe class.private static final ClassInjector.UsingUnsafe.Dispatcher.Initializable DISPATCHER
private static final java.lang.Object BOOTSTRAP_LOADER_LOCK
@HashCodeAndEqualsPlugin.ValueHandling(value=REVERSE_NULLABILITY) private final java.lang.ClassLoader classLoader
null for the bootstrap loader.@HashCodeAndEqualsPlugin.ValueHandling(value=REVERSE_NULLABILITY) private final java.security.ProtectionDomain protectionDomain
null for no protection domain.public UsingUnsafe(java.lang.ClassLoader classLoader)
classLoader - The class loader to inject classes into or null for the bootstrap loader.public UsingUnsafe(java.lang.ClassLoader classLoader,
java.security.ProtectionDomain protectionDomain)
classLoader - The class loader to inject classes into or null for the bootstrap loader.protectionDomain - The protection domain to use or null for no protection domain.public boolean isAlive()
true if this injector is available on the current VM.public java.util.Map<java.lang.String,java.lang.Class<?>> injectRaw(java.util.Map<? extends java.lang.String,byte[]> types)
types - The types to load via injection.public static boolean isAvailable()
true if unsafe class injection is available on the current VM.public static ClassInjector ofSystemLoader()
public static ClassInjector ofPlatformLoader()
public static ClassInjector ofBootLoader()