Package net.bytebuddy.dynamic.loading
Class ClassInjector.UsingInstrumentation
java.lang.Object
net.bytebuddy.dynamic.loading.ClassInjector.AbstractBase
net.bytebuddy.dynamic.loading.ClassInjector.UsingInstrumentation
- All Implemented Interfaces:
ClassInjector
- Enclosing interface:
ClassInjector
A class injector using a
Instrumentation
to append to either the boot classpath
or the system class path.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interface
A dispatcher to interact with the instrumentation API.static enum
A representation of the target to which Java classes should be appended to.Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.loading.ClassInjector
ClassInjector.AbstractBase, ClassInjector.UsingInstrumentation, ClassInjector.UsingJna, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The class file extension.private static final ClassInjector.UsingInstrumentation.Dispatcher
A dispatcher for interacting with the instrumentation API.private final File
The folder to be used for storing jar files.private final Instrumentation
The instrumentation to use for appending to the class path or the boot path.private static final String
The jar file name extension.private final RandomString
A random string generator for creating file names.private final ClassInjector.UsingInstrumentation.Target
A representation of the target path to which classes are to be appended.Fields inherited from interface net.bytebuddy.dynamic.loading.ClassInjector
ALLOW_EXISTING_TYPES, SUPPRESS_ACCESS_CHECKS
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
UsingInstrumentation
(File folder, ClassInjector.UsingInstrumentation.Target target, Instrumentation instrumentation, RandomString randomString) Creates an instrumentation-based class injector. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> T
doPrivileged
(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivileged
that is activated if available.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
Returnstrue
if this class injector is available on this VM.static ClassInjector
of
(File folder, ClassInjector.UsingInstrumentation.Target target, Instrumentation instrumentation) Creates an instrumentation-based class injector.static void
redefineModule
(Instrumentation instrumentation, JavaModule target, Set<JavaModule> reads, Map<String, Set<JavaModule>> exports, Map<String, Set<JavaModule>> opens, Set<Class<?>> uses, Map<Class<?>, List<Class<?>>> provides) Modifies a module's properties usingInstrumentation
.Methods inherited from class net.bytebuddy.dynamic.loading.ClassInjector.AbstractBase
inject
-
Field Details
-
JAR
The jar file name extension.- See Also:
-
CLASS_FILE_EXTENSION
The class file extension.- See Also:
-
DISPATCHER
A dispatcher for interacting with the instrumentation API. -
instrumentation
The instrumentation to use for appending to the class path or the boot path. -
target
A representation of the target path to which classes are to be appended. -
folder
The folder to be used for storing jar files. -
randomString
A random string generator for creating file names.
-
-
Constructor Details
-
UsingInstrumentation
protected UsingInstrumentation(File folder, ClassInjector.UsingInstrumentation.Target target, Instrumentation instrumentation, RandomString randomString) Creates an instrumentation-based class injector.- Parameters:
folder
- The folder to be used for storing jar files.target
- A representation of the target path to which classes are to be appended.instrumentation
- The instrumentation to use for appending to the class path or the boot path.randomString
- The random string generator to use.
-
-
Method Details
-
doPrivileged
A proxy forjava.security.AccessController#doPrivileged
that is activated if available.- Type Parameters:
T
- The type of the action's resolved value.- Parameters:
action
- The action to execute from a privileged context.- Returns:
- The action's resolved value.
-
redefineModule
public static void redefineModule(Instrumentation instrumentation, JavaModule target, Set<JavaModule> reads, Map<String, Set<JavaModule>> exports, Map<String, Set<JavaModule>> opens, Set<Class<?>> uses, Map<Class<?>, List<Class<?>>> provides) Modifies a module's properties usingInstrumentation
.- Parameters:
instrumentation
- TheInstrumentation
instance to use for applying the modification.target
- The target module that should be modified.reads
- A set of additional modules this module should read.exports
- A map of packages to export to a set of modules.opens
- A map of packages to open to a set of modules.uses
- A set of provider interfaces to use by this module.provides
- A map of provider interfaces to provide by this module mapped to the provider implementations.
-
of
public static ClassInjector of(File folder, ClassInjector.UsingInstrumentation.Target target, Instrumentation instrumentation) Creates an instrumentation-based class injector.- Parameters:
folder
- The folder to be used for storing jar files.target
- A representation of the target path to which classes are to be appended.instrumentation
- The instrumentation to use for appending to the class path or the boot path.- Returns:
- An appropriate class injector that applies instrumentation.
-
isAlive
public boolean isAlive()Indicates if this class injector is available on the current VM.- Returns:
true
if this injector is available on the current VM.
-
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.
-
isAvailable
public static boolean isAvailable()Returnstrue
if this class injector is available on this VM.- Returns:
true
if this class injector is available on this VM.
-