Package net.bytebuddy.dynamic.loading
Interface ClassInjector
- All Known Implementing Classes:
ClassInjector.AbstractBase
,ClassInjector.UsingInstrumentation
,ClassInjector.UsingJna
,ClassInjector.UsingLookup
,ClassInjector.UsingReflection
,ClassInjector.UsingUnsafe
public interface ClassInjector
A class injector is capable of injecting classes into a ClassLoader
without
requiring the class loader to being able to explicitly look up these classes.
Important: Byte Buddy does not supply privileges when injecting code. When using a java.lang.SecurityManager
,
the user of this injector is responsible for providing access to non-public properties.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
An abstract base implementation of a class injector.static class
A class injector using aInstrumentation
to append to either the boot classpath or the system class path.static class
A class injector using JNA to invoke JNI's define class utility for defining a class.static class
A class injector that uses ajava.lang.invoke.MethodHandles$Lookup
object for defining a class.static class
A class injector that uses reflective method calls.static class
A class injector that usessun.misc.Unsafe
orjdk.internal.misc.Unsafe
to inject classes. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
Determines the default behavior for type injections when a type is already loaded.static final Permission
A permission for thesuppressAccessChecks
permission. -
Method Summary
Modifier and TypeMethodDescriptionMap<TypeDescription,
Class<?>> inject
(Map<? extends TypeDescription, byte[]> types) Injects the given types into the represented class loader.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.
-
Field Details
-
SUPPRESS_ACCESS_CHECKS
A permission for thesuppressAccessChecks
permission. -
ALLOW_EXISTING_TYPES
static final boolean ALLOW_EXISTING_TYPESDetermines the default behavior for type injections when a type is already loaded.- See Also:
-
-
Method Details
-
isAlive
boolean isAlive()Indicates if this class injector is available on the current VM.- Returns:
true
if this injector is available on the current VM.
-
inject
Injects the given types into the represented class loader.- Parameters:
types
- The types to load via injection.- Returns:
- The loaded types that were passed as arguments.
-
injectRaw
Injects the given types into the represented class loader using a mapping from name to binary representation.- Parameters:
types
- The types to load via injection.- Returns:
- The loaded types that were passed as arguments.
-