Package net.bytebuddy.dynamic
Class ClassFileLocator.ForInstrumentation.ClassLoadingDelegate.Explicit
java.lang.Object
net.bytebuddy.dynamic.ClassFileLocator.ForInstrumentation.ClassLoadingDelegate.Explicit
- All Implemented Interfaces:
ClassFileLocator.ForInstrumentation.ClassLoadingDelegate
- Enclosing interface:
- ClassFileLocator.ForInstrumentation.ClassLoadingDelegate
@Enhance
public static class ClassFileLocator.ForInstrumentation.ClassLoadingDelegate.Explicit
extends Object
implements ClassFileLocator.ForInstrumentation.ClassLoadingDelegate
A class loading delegate that allows the location of explicitly registered classes that cannot
be located by a class loader directly. This allows for locating classes that are loaded by
an anonymous class loader which does not register its classes in a system dictionary.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.ClassFileLocator.ForInstrumentation.ClassLoadingDelegate
ClassFileLocator.ForInstrumentation.ClassLoadingDelegate.Default, ClassFileLocator.ForInstrumentation.ClassLoadingDelegate.Explicit, ClassFileLocator.ForInstrumentation.ClassLoadingDelegate.ForDelegatingClassLoader
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassFileLocator.ForInstrumentation.ClassLoadingDelegate
A class loading delegate that is queried for classes that are not registered explicitly.The map of registered classes mapped by their name. -
Constructor Summary
ConstructorsConstructorDescriptionExplicit
(ClassLoader classLoader, Collection<? extends Class<?>> types) Creates a new class loading delegate with a possibility of looking up explicitly registered classes.Explicit
(ClassFileLocator.ForInstrumentation.ClassLoadingDelegate fallbackDelegate, Collection<? extends Class<?>> types) Creates a new class loading delegate with a possibility of looking up explicitly registered classes. -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlying class loader.Class<?>
Loads a class by its name.Creates an explicit class loading delegate for the given type.
-
Field Details
-
fallbackDelegate
A class loading delegate that is queried for classes that are not registered explicitly. -
types
The map of registered classes mapped by their name.
-
-
Constructor Details
-
Explicit
Creates a new class loading delegate with a possibility of looking up explicitly registered classes.- Parameters:
classLoader
- The class loader to be used for looking up classes.types
- A collection of classes that cannot be looked up explicitly.
-
Explicit
public Explicit(ClassFileLocator.ForInstrumentation.ClassLoadingDelegate fallbackDelegate, Collection<? extends Class<?>> types) Creates a new class loading delegate with a possibility of looking up explicitly registered classes.- Parameters:
fallbackDelegate
- The class loading delegate to query for any class that is not registered explicitly.types
- A collection of classes that cannot be looked up explicitly.
-
-
Method Details
-
of
Creates an explicit class loading delegate for the given type.- Parameters:
type
- The type that is explicitly locatable.- Returns:
- A suitable class loading delegate.
-
locate
Loads a class by its name.- Specified by:
locate
in interfaceClassFileLocator.ForInstrumentation.ClassLoadingDelegate
- Parameters:
name
- The name of the type.- Returns:
- The class with the given name.
- Throws:
ClassNotFoundException
- If a class cannot be found.
-
getClassLoader
Returns the underlying class loader.- Specified by:
getClassLoader
in interfaceClassFileLocator.ForInstrumentation.ClassLoadingDelegate
- Returns:
- The underlying class loader.
-