@HashCodeAndEqualsPlugin.Enhance public static class ClassInjector.UsingReflection extends ClassInjector.AbstractBase
Modifier and Type | Class and Description |
---|---|
protected static interface |
ClassInjector.UsingReflection.Dispatcher
A dispatcher for accessing a
ClassLoader reflectively. |
protected static interface |
ClassInjector.UsingReflection.System
A proxy of
java.lang.System . |
ClassInjector.AbstractBase, ClassInjector.UsingInstrumentation, ClassInjector.UsingJna, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe
ALLOW_EXISTING_TYPES, SUPPRESS_ACCESS_CHECKS
Constructor and Description |
---|
UsingReflection(ClassLoader classLoader)
Creates a new injector for the given
ClassLoader and a default ProtectionDomain and a
trivial PackageDefinitionStrategy which does not trigger an error when discovering existent classes. |
UsingReflection(ClassLoader classLoader,
ProtectionDomain protectionDomain)
Creates a new injector for the given
ClassLoader and a default PackageDefinitionStrategy where the
injection of existent classes does not trigger an error. |
UsingReflection(ClassLoader classLoader,
ProtectionDomain protectionDomain,
PackageDefinitionStrategy packageDefinitionStrategy,
boolean forbidExisting)
Creates a new injector for the given
ClassLoader and ProtectionDomain . |
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()
Indicates if this class injection is available on the current VM.
|
static ClassInjector |
ofSystemClassLoader()
Creates a class injector for the system class loader.
|
inject
public UsingReflection(ClassLoader classLoader)
ClassLoader
and a default ProtectionDomain
and a
trivial PackageDefinitionStrategy
which does not trigger an error when discovering existent classes.classLoader
- The ClassLoader
into which new class definitions are to be injected. Must not be the bootstrap loader.public UsingReflection(ClassLoader classLoader, @MaybeNull ProtectionDomain protectionDomain)
ClassLoader
and a default PackageDefinitionStrategy
where the
injection of existent classes does not trigger an error.classLoader
- The ClassLoader
into which new class definitions are to be injected. Must not be the bootstrap loader.protectionDomain
- The protection domain to apply during class definition.public UsingReflection(ClassLoader classLoader, @MaybeNull ProtectionDomain protectionDomain, PackageDefinitionStrategy packageDefinitionStrategy, boolean forbidExisting)
ClassLoader
and ProtectionDomain
.classLoader
- The ClassLoader
into which new class definitions are to be injected.Must not be the bootstrap loader.protectionDomain
- The protection domain to apply during class definition.packageDefinitionStrategy
- The package definer to be queried for package definitions.forbidExisting
- Determines if an exception should be thrown when attempting to load a type that already exists.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 this class injection is available.public static ClassInjector ofSystemClassLoader()
Copyright © 2014–2024. All rights reserved.