Package net.bytebuddy.dynamic.loading
Class ClassInjector.UsingUnsafe
- java.lang.Object
-
- net.bytebuddy.dynamic.loading.ClassInjector.UsingUnsafe
-
- All Implemented Interfaces:
ClassInjector
- Enclosing interface:
- ClassInjector
public static class ClassInjector.UsingUnsafe extends java.lang.Object implements ClassInjector
A class injector that usessun.misc.Unsafeto inject classes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.loading.ClassInjector
ClassInjector.UsingInstrumentation, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe
-
-
Field Summary
-
Fields inherited from interface net.bytebuddy.dynamic.loading.ClassInjector
ALLOW_EXISTING_TYPES
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<TypeDescription,java.lang.Class<?>>inject(java.util.Map<? extends TypeDescription,byte[]> types)Injects the given types into the represented class loader.static booleanisAvailable()Checks if unsafe class injection is available on the current VM.static ClassInjectorofBootstrapLoader()Returns an unsafe class injector for the bootstrap class loader.static ClassInjectorofClassPath()Returns an unsafe class injector for the class path.
-
-
-
Constructor Detail
-
UsingUnsafe
public UsingUnsafe(java.lang.ClassLoader classLoader)
Creates a new unsafe injector for the given class loader with a default protection domain.- Parameters:
classLoader- The class loader to inject classes into ornullfor the bootstrap loader.
-
UsingUnsafe
public UsingUnsafe(java.lang.ClassLoader classLoader, java.security.ProtectionDomain protectionDomain)Creates a new unsafe injector for the given class loader with a default protection domain.- Parameters:
classLoader- The class loader to inject classes into ornullfor the bootstrap loader.protectionDomain- The protection domain to use ornullfor no protection domain.
-
-
Method Detail
-
isAvailable
public static boolean isAvailable()
Checks if unsafe class injection is available on the current VM.- Returns:
trueif unsafe class injection is available on the current VM.
-
ofBootstrapLoader
public static ClassInjector ofBootstrapLoader()
Returns an unsafe class injector for the bootstrap class loader.- Returns:
- A class injector for the bootstrap loader.
-
ofClassPath
public static ClassInjector ofClassPath()
Returns an unsafe class injector for the class path.- Returns:
- A class injector for the system class loader.
-
inject
public java.util.Map<TypeDescription,java.lang.Class<?>> inject(java.util.Map<? extends TypeDescription,byte[]> types)
Description copied from interface:ClassInjectorInjects the given types into the represented class loader.- Specified by:
injectin interfaceClassInjector- Parameters:
types- The types to load via injection.- Returns:
- The loaded types that were passed as arguments.
-
-