Package net.bytebuddy.dynamic
Class ClassFileLocator.AgentBased.ClassLoadingDelegate.Explicit
- java.lang.Object
-
- net.bytebuddy.dynamic.ClassFileLocator.AgentBased.ClassLoadingDelegate.Explicit
-
- All Implemented Interfaces:
ClassFileLocator.AgentBased.ClassLoadingDelegate
- Enclosing interface:
- ClassFileLocator.AgentBased.ClassLoadingDelegate
@Enhance public static class ClassFileLocator.AgentBased.ClassLoadingDelegate.Explicit extends java.lang.Object implements ClassFileLocator.AgentBased.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.AgentBased.ClassLoadingDelegate
ClassFileLocator.AgentBased.ClassLoadingDelegate.Default, ClassFileLocator.AgentBased.ClassLoadingDelegate.Explicit, ClassFileLocator.AgentBased.ClassLoadingDelegate.ForDelegatingClassLoader
-
-
Field Summary
Fields Modifier and Type Field Description private ClassFileLocator.AgentBased.ClassLoadingDelegatefallbackDelegateA class loading delegate that is queried for classes that are not registered explicitly.private java.util.Map<java.lang.String,java.lang.Class<?>>typesThe map of registered classes mapped by their name.
-
Constructor Summary
Constructors Constructor Description Explicit(java.lang.ClassLoader classLoader, java.util.Collection<? extends java.lang.Class<?>> types)Creates a new class loading delegate with a possibility of looking up explicitly registered classes.Explicit(ClassFileLocator.AgentBased.ClassLoadingDelegate fallbackDelegate, java.util.Collection<? extends java.lang.Class<?>> types)Creates a new class loading delegate with a possibility of looking up explicitly registered classes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ClassLoadergetClassLoader()Returns the underlying class loader.java.lang.Class<?>locate(java.lang.String name)Loads a class by its name.static ClassFileLocator.AgentBased.ClassLoadingDelegateof(java.lang.Class<?> type)Creates an explicit class loading delegate for the given type.
-
-
-
Field Detail
-
fallbackDelegate
private final ClassFileLocator.AgentBased.ClassLoadingDelegate fallbackDelegate
A class loading delegate that is queried for classes that are not registered explicitly.
-
types
private final java.util.Map<java.lang.String,java.lang.Class<?>> types
The map of registered classes mapped by their name.
-
-
Constructor Detail
-
Explicit
public Explicit(java.lang.ClassLoader classLoader, java.util.Collection<? extends java.lang.Class<?>> types)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.AgentBased.ClassLoadingDelegate fallbackDelegate, java.util.Collection<? extends java.lang.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 Detail
-
of
public static ClassFileLocator.AgentBased.ClassLoadingDelegate of(java.lang.Class<?> type)
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
public java.lang.Class<?> locate(java.lang.String name) throws java.lang.ClassNotFoundExceptionLoads a class by its name.- Specified by:
locatein interfaceClassFileLocator.AgentBased.ClassLoadingDelegate- Parameters:
name- The name of the type.- Returns:
- The class with the given name.
- Throws:
java.lang.ClassNotFoundException- If a class cannot be found.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Returns the underlying class loader.- Specified by:
getClassLoaderin interfaceClassFileLocator.AgentBased.ClassLoadingDelegate- Returns:
- The underlying class loader.
-
-