Package net.bytebuddy.dynamic.loading
Class ByteArrayClassLoader.ChildFirst
java.lang.Object
java.lang.ClassLoader
net.bytebuddy.dynamic.loading.InjectionClassLoader
net.bytebuddy.dynamic.loading.ByteArrayClassLoader
net.bytebuddy.dynamic.loading.ByteArrayClassLoader.ChildFirst
- Enclosing class:
ByteArrayClassLoader
A ByteArrayClassLoader
which applies child-first semantics for the
given type definitions.
Important: Package definitions remain their parent-first semantics as loaded package definitions do not expose their class loaders. Also, it is not possible to make this class or its subclass parallel-capable as the loading strategy is overridden.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
An enumeration that prepends an element to another enumeration and skips the last element of the provided enumeration.Nested classes/interfaces inherited from class net.bytebuddy.dynamic.loading.ByteArrayClassLoader
ByteArrayClassLoader.ChildFirst, ByteArrayClassLoader.ClassDefinitionAction, ByteArrayClassLoader.EmptyEnumeration, ByteArrayClassLoader.PackageLookupStrategy, ByteArrayClassLoader.PersistenceHandler, ByteArrayClassLoader.SingletonEnumeration, ByteArrayClassLoader.SynchronizationStrategy
Nested classes/interfaces inherited from class net.bytebuddy.dynamic.loading.InjectionClassLoader
InjectionClassLoader.Strategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The suffix of files in the Java class file format.Fields inherited from class net.bytebuddy.dynamic.loading.ByteArrayClassLoader
accessControlContext, classFilePostProcessor, packageDefinitionStrategy, persistenceHandler, protectionDomain, SYNCHRONIZATION_STRATEGY, typeDefinitions, URL_SCHEMA
-
Constructor Summary
ConstructorsConstructorDescriptionChildFirst
(ClassLoader parent, boolean sealed, Map<String, byte[]> typeDefinitions) Creates a new child-first byte array class loader.ChildFirst
(ClassLoader parent, boolean sealed, Map<String, byte[]> typeDefinitions, ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy) Creates a new child-first byte array class loader.ChildFirst
(ClassLoader parent, boolean sealed, Map<String, byte[]> typeDefinitions, ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy, ClassFilePostProcessor classFilePostProcessor) Creates a new child-first byte array class loader.ChildFirst
(ClassLoader parent, boolean sealed, Map<String, byte[]> typeDefinitions, ByteArrayClassLoader.PersistenceHandler persistenceHandler) Creates a new child-first byte array class loader.ChildFirst
(ClassLoader parent, Map<String, byte[]> typeDefinitions) Creates a new child-first byte array class loader.ChildFirst
(ClassLoader parent, Map<String, byte[]> typeDefinitions, ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy) Creates a new child-first byte array class loader.ChildFirst
(ClassLoader parent, Map<String, byte[]> typeDefinitions, ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy, ClassFilePostProcessor classFilePostProcessor) Creates a new child-first byte array class loader.ChildFirst
(ClassLoader parent, Map<String, byte[]> typeDefinitions, ByteArrayClassLoader.PersistenceHandler persistenceHandler) Creates a new child-first byte array class loader. -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
Registers class loader as parallel capable if possible.getResource
(String name) getResources
(String name) private boolean
isShadowed
(String resource) Checks if a resource name represents a class file of a class that was loaded by this class loader.static Map
<TypeDescription, Class<?>> load
(ClassLoader classLoader, Map<TypeDescription, byte[]> types) Loads a given set of class descriptions and their binary representations using a child-first class loader.static Map
<TypeDescription, Class<?>> load
(ClassLoader classLoader, Map<TypeDescription, byte[]> types, ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy, boolean forbidExisting, boolean sealed) Loads a given set of class descriptions and their binary representations using a child-first class loader.protected Class
<?> Methods inherited from class net.bytebuddy.dynamic.loading.ByteArrayClassLoader
doDefineClasses, findClass, findResource, findResources
Methods inherited from class net.bytebuddy.dynamic.loading.InjectionClassLoader
defineClass, defineClasses, isSealed, seal
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResourceAsStream, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
CLASS_FILE_SUFFIX
The suffix of files in the Java class file format.- See Also:
-
-
Constructor Details
-
ChildFirst
Creates a new child-first byte array class loader.- Parameters:
parent
- TheClassLoader
that is the parent of this class loader.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.
-
ChildFirst
public ChildFirst(@MaybeNull ClassLoader parent, boolean sealed, Map<String, byte[]> typeDefinitions) Creates a new child-first byte array class loader.- Parameters:
parent
- TheClassLoader
that is the parent of this class loader.sealed
-true
if this class loader is sealed.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.
-
ChildFirst
public ChildFirst(@MaybeNull ClassLoader parent, Map<String, byte[]> typeDefinitions, ByteArrayClassLoader.PersistenceHandler persistenceHandler) Creates a new child-first byte array class loader.- Parameters:
parent
- TheClassLoader
that is the parent of this class loader.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.persistenceHandler
- The persistence handler of this class loader.
-
ChildFirst
public ChildFirst(@MaybeNull ClassLoader parent, boolean sealed, Map<String, byte[]> typeDefinitions, ByteArrayClassLoader.PersistenceHandler persistenceHandler) Creates a new child-first byte array class loader.- Parameters:
parent
- TheClassLoader
that is the parent of this class loader.sealed
-true
if this class loader is sealed.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.persistenceHandler
- The persistence handler of this class loader.
-
ChildFirst
public ChildFirst(@MaybeNull ClassLoader parent, Map<String, byte[]> typeDefinitions, @MaybeNull ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy) Creates a new child-first byte array class loader.- Parameters:
parent
- TheClassLoader
that is the parent of this class loader.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.protectionDomain
- The protection domain to apply wherenull
references an implicit protection domain.persistenceHandler
- The persistence handler of this class loader.packageDefinitionStrategy
- The package definer to be queried for package definitions.
-
ChildFirst
public ChildFirst(@MaybeNull ClassLoader parent, boolean sealed, Map<String, byte[]> typeDefinitions, @MaybeNull ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy) Creates a new child-first byte array class loader.- Parameters:
parent
- TheClassLoader
that is the parent of this class loader.sealed
-true
if this class loader is sealed.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.protectionDomain
- The protection domain to apply wherenull
references an implicit protection domain.persistenceHandler
- The persistence handler of this class loader.packageDefinitionStrategy
- The package definer to be queried for package definitions.
-
ChildFirst
public ChildFirst(@MaybeNull ClassLoader parent, Map<String, byte[]> typeDefinitions, @MaybeNull ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy, ClassFilePostProcessor classFilePostProcessor) Creates a new child-first byte array class loader.- Parameters:
parent
- TheClassLoader
that is the parent of this class loader.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.protectionDomain
- The protection domain to apply wherenull
references an implicit protection domain.persistenceHandler
- The persistence handler of this class loader.packageDefinitionStrategy
- The package definer to be queried for package definitions.classFilePostProcessor
- A post processor for class files to apply p
-
ChildFirst
public ChildFirst(@MaybeNull ClassLoader parent, boolean sealed, Map<String, byte[]> typeDefinitions, @MaybeNull ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy, ClassFilePostProcessor classFilePostProcessor) Creates a new child-first byte array class loader.- Parameters:
parent
- TheClassLoader
that is the parent of this class loader.sealed
-true
if this class loader is sealed.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.protectionDomain
- The protection domain to apply wherenull
references an implicit protection domain.persistenceHandler
- The persistence handler of this class loader.packageDefinitionStrategy
- The package definer to be queried for package definitions.classFilePostProcessor
- A post processor for class files to apply p
-
-
Method Details
-
doRegisterAsParallelCapable
private static void doRegisterAsParallelCapable()Registers class loader as parallel capable if possible. -
load
public static Map<TypeDescription,Class<?>> load(@MaybeNull ClassLoader classLoader, Map<TypeDescription, byte[]> types) Loads a given set of class descriptions and their binary representations using a child-first class loader.- Parameters:
classLoader
- The parent class loader.types
- The unloaded types to be loaded.- Returns:
- A map of the given type descriptions pointing to their loaded representations.
-
load
public static Map<TypeDescription,Class<?>> load(@MaybeNull ClassLoader classLoader, Map<TypeDescription, byte[]> types, @MaybeNull ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, PackageDefinitionStrategy packageDefinitionStrategy, boolean forbidExisting, boolean sealed) Loads a given set of class descriptions and their binary representations using a child-first class loader.- Parameters:
classLoader
- The parent class loader.types
- The unloaded types to be loaded.protectionDomain
- The protection domain to apply wherenull
references an implicit protection domain.persistenceHandler
- The persistence handler of the created class loader.packageDefinitionStrategy
- The package definer to be queried for package definitions.forbidExisting
-true
if the class loading should throw an exception if a class was already loaded by a parent class loader.sealed
-true
if the class loader should be sealed.- Returns:
- A map of the given type descriptions pointing to their loaded representations.
-
loadClass
- Overrides:
loadClass
in classClassLoader
- Throws:
ClassNotFoundException
-
getResource
- Overrides:
getResource
in classClassLoader
-
getResources
- Overrides:
getResources
in classClassLoader
- Throws:
IOException
-
isShadowed
Checks if a resource name represents a class file of a class that was loaded by this class loader.- Parameters:
resource
- The resource name of the class to be exposed as its class file.- Returns:
true
if this class represents a class that is being loaded by this class loader.
-