Class ClassInjector.UsingReflection
java.lang.Object
net.bytebuddy.dynamic.loading.ClassInjector.AbstractBase
net.bytebuddy.dynamic.loading.ClassInjector.UsingReflection
- All Implemented Interfaces:
ClassInjector
- Enclosing interface:
ClassInjector
A class injector that uses reflective method calls.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceA dispatcher for accessing aClassLoaderreflectively.protected static interfaceA proxy ofjava.lang.System.Nested classes/interfaces inherited from interface ClassInjector
ClassInjector.AbstractBase, ClassInjector.UsingInstrumentation, ClassInjector.UsingJna, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe -
Field Summary
Fields inherited from class ClassInjector.AbstractBase
SUPPRESS_ACCESS_CHECKSFields inherited from interface ClassInjector
ALLOW_EXISTING_TYPES -
Constructor Summary
ConstructorsConstructorDescriptionUsingReflection(ClassLoader classLoader) Creates a new injector for the givenClassLoaderand a defaultProtectionDomainand a trivialPackageDefinitionStrategywhich does not trigger an error when discovering existent classes.UsingReflection(ClassLoader classLoader, ProtectionDomain protectionDomain) Creates a new injector for the givenClassLoaderand a defaultPackageDefinitionStrategywhere 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 givenClassLoaderandProtectionDomain. -
Method Summary
Modifier and TypeMethodDescriptioninjectRaw(Set<String> names, ClassFileLocator classFileLocator) Injects the given types into the represented class loader.booleanisAlive()Indicates if this class injector is available on the current VM.static booleanIndicates if this class injection is available on the current VM.static ClassInjectorCreates a class injector for the system class loader.Methods inherited from class ClassInjector.AbstractBase
inject, inject, injectRaw
-
Constructor Details
-
UsingReflection
Creates a new injector for the givenClassLoaderand a defaultProtectionDomainand a trivialPackageDefinitionStrategywhich does not trigger an error when discovering existent classes.- Parameters:
classLoader- TheClassLoaderinto which new class definitions are to be injected. Must not be the bootstrap loader.
-
UsingReflection
Creates a new injector for the givenClassLoaderand a defaultPackageDefinitionStrategywhere the injection of existent classes does not trigger an error.- Parameters:
classLoader- TheClassLoaderinto which new class definitions are to be injected. Must not be the bootstrap loader.protectionDomain- The protection domain to apply during class definition.
-
UsingReflection
public UsingReflection(ClassLoader classLoader, @MaybeNull ProtectionDomain protectionDomain, PackageDefinitionStrategy packageDefinitionStrategy, boolean forbidExisting) Creates a new injector for the givenClassLoaderandProtectionDomain.- Parameters:
classLoader- TheClassLoaderinto 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.
-
-
Method Details
-
isAlive
public boolean isAlive()Indicates if this class injector is available on the current VM.- Returns:
trueif this injector is available on the current VM.
-
injectRaw
Injects the given types into the represented class loader.- Parameters:
names- The names of the types to load via injection.classFileLocator- The class file locator to use for resolving binary representations.- Returns:
- The loaded types that were passed as arguments.
-
isAvailable
public static boolean isAvailable()Indicates if this class injection is available on the current VM.- Returns:
trueif this class injection is available.
-
ofSystemClassLoader
Creates a class injector for the system class loader.- Returns:
- A class injector for the system class loader.
-