Package net.bytebuddy.dynamic.loading
Class ClassInjector.UsingUnsafe.Dispatcher.Enabled
java.lang.Object
net.bytebuddy.dynamic.loading.ClassInjector.UsingUnsafe.Dispatcher.Enabled
- All Implemented Interfaces:
ClassInjector.UsingUnsafe.Dispatcher
,ClassInjector.UsingUnsafe.Dispatcher.Initializable
- Enclosing interface:
ClassInjector.UsingUnsafe.Dispatcher
@Enhance
public static class ClassInjector.UsingUnsafe.Dispatcher.Enabled
extends Object
implements ClassInjector.UsingUnsafe.Dispatcher, ClassInjector.UsingUnsafe.Dispatcher.Initializable
An enabled dispatcher.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.loading.ClassInjector.UsingUnsafe.Dispatcher
ClassInjector.UsingUnsafe.Dispatcher.CreationAction, ClassInjector.UsingUnsafe.Dispatcher.Enabled, ClassInjector.UsingUnsafe.Dispatcher.Initializable, ClassInjector.UsingUnsafe.Dispatcher.Unavailable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClass
<?> defineClass
(ClassLoader classLoader, String name, byte[] binaryRepresentation, ProtectionDomain protectionDomain) Defines a class.Initializes the dispatcher.boolean
Checks if unsafe class injection is available on the current VM.
-
Field Details
-
unsafe
An instance ofsun.misc.Unsafe
orjdk.internal.misc.Unsafe
. -
defineClass
Thesun.misc.Unsafe#defineClass
orjdk.internal.misc.Unsafe#defineClass
method.
-
-
Constructor Details
-
Enabled
Creates an enabled dispatcher.- Parameters:
unsafe
- An instance ofsun.misc.Unsafe
orjdk.internal.misc.Unsafe
.defineClass
- Thesun.misc.Unsafe#defineClass
orjdk.internal.misc.Unsafe#defineClass
method.
-
-
Method Details
-
isAvailable
public boolean isAvailable()Checks if unsafe class injection is available on the current VM.- Specified by:
isAvailable
in interfaceClassInjector.UsingUnsafe.Dispatcher.Initializable
- Returns:
true
if unsafe class injection is available.
-
initialize
Initializes the dispatcher.- Specified by:
initialize
in interfaceClassInjector.UsingUnsafe.Dispatcher.Initializable
- Returns:
- The initialized dispatcher.
-
defineClass
public Class<?> defineClass(@MaybeNull ClassLoader classLoader, String name, byte[] binaryRepresentation, @MaybeNull ProtectionDomain protectionDomain) Defines a class.- Specified by:
defineClass
in interfaceClassInjector.UsingUnsafe.Dispatcher
- Parameters:
classLoader
- The class loader to inject the class into.name
- The type's name.binaryRepresentation
- The type's binary representation.protectionDomain
- The type's protection domain.- Returns:
- The defined class.
-