@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 |
---|---|
static 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(ClassLoader classLoader)
Creates a new unsafe injector for the given class loader with a default protection domain.
|
UsingUnsafe(ClassLoader classLoader,
ProtectionDomain protectionDomain)
Creates a new unsafe injector for the given class loader with a default protection domain.
|
Modifier and Type | Method and Description |
---|---|
Map<String,Class<?>> |
injectRaw(Map<? extends 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.
|
inject
public static final String SAFE_PROPERTY
Unsafe
class.public UsingUnsafe(ClassLoader classLoader)
classLoader
- The class loader to inject classes into or null
for the bootstrap loader.public UsingUnsafe(ClassLoader classLoader, 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 Map<String,Class<?>> injectRaw(Map<? extends 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()
Copyright © 2014–2018. All rights reserved.