This java. is capable of loading classes from multiple parents. This class loader
implicitly defines the bootstrap class loader to be its direct parent as it is required for all class loaders.
This can be useful when creating a type that inherits a super type and interfaces that are defined by different,
non-compatible class loaders.
Note
Instances of this class loader can have the same class loader as its parent multiple times,
either directly or indirectly by multiple parents sharing a common parent class loader. By definition,
this implies that the bootstrap class loader is #(direct parents) + 1 times a parent of this class loader.
For the java. method, this means that this class loader
might return the same url multiple times by representing the same class loader multiple times.
Important Note
This class loader does not support the location of packages from its multiple parents. This breaks package equality when loading classes by either loading them directly via this class loader (e.g. by subclassing) or by loading classes with child class loaders of this class loader.
| Modifier and Type | Class and Description |
|---|---|
| public static class | MultipleParentClassLoader.Builder
A builder to collect class loader and that creates a
|
| protected static class | MultipleParentClassLoader.CompoundEnumeration
A compound URL enumeration. |
| Modifier and Type | Field and Description |
|---|---|
| private final List | parents
The parents of this class loader in their application order. |
| Access | Constructor and Description |
|---|---|
| public | MultipleParentClassLoader(List<? extends ClassLoader>
The parents of this class loader in their application order. This list must not contain parents)null,
i.e. the bootstrap class loader which is an implicit parent of any class loader.Creates a new class loader with multiple parents. |
| public | MultipleParentClassLoader(ClassLoader
An explicit parent in compliance with the class loader API. This explicit parent should only be set if
the current platform does not allow creating a class loader that extends the bootstrap loader. parent, List<? extends ClassLoader> The parents of this class loader in their application order. This list must not contain parents)null,
i.e. the bootstrap class loader which is an implicit parent of any class loader.Creates a new class loader with multiple parents. |
| public | MultipleParentClassLoader(ClassLoader
An explicit parent in compliance with the class loader API. This explicit parent should only be set if
the current platform does not allow creating a class loader that extends the bootstrap loader. parent, List<? extends ClassLoader> The parents of this class loader in their application order. This list must not contain parents, boolean null,
i.e. the bootstrap class loader which is an implicit parent of any class loader.true if the class loader is sealed for injection of additional classes.Creates a new class loader with multiple parents. |
| Modifier and Type | Method and Description |
|---|---|
| protected Map | doDefineClasses(Map<String, byte[]>
The types binary representations. typeDefinitions)Implements abstract net. |
| private static void | doRegisterAsParallelCapable()
Hides net. |
| public URL | getResource(String
The resource name name)Overrides java. |
| public Enumeration | getResources(String
The resource name name)Overrides java. |
| protected Class | loadClass(String
The binary name of the class name, boolean If resolve)true then resolve the classOverrides java. |
| parents | back to summary |
|---|---|
| private final List<? extends ClassLoader> parents The parents of this class loader in their application order. | |
| MultipleParentClassLoader | back to summary |
|---|---|
| public MultipleParentClassLoader(List<? extends ClassLoader> parents) Creates a new class loader with multiple parents.
| |
| MultipleParentClassLoader | back to summary |
|---|---|
| public MultipleParentClassLoader(ClassLoader parent, List<? extends ClassLoader> parents) Creates a new class loader with multiple parents.
| |
| MultipleParentClassLoader | back to summary |
|---|---|
| public MultipleParentClassLoader(ClassLoader parent, List<? extends ClassLoader> parents, boolean sealed) Creates a new class loader with multiple parents.
| |
| doDefineClasses | back to summary |
|---|---|
| protected Map Implements abstract net. Doc from net. Defines a group of types to be loaded by this class loader. | |
| doRegisterAsParallelCapable | back to summary |
|---|---|
| private static void doRegisterAsParallelCapable() Hides net. Registers class loader as parallel capable if possible.
| |
| getResource | back to summary |
|---|---|
| public URL getResource(String name) Overrides java. Doc from java. Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code. The name of a resource is a ' Resources in named modules are subject to the encapsulation rules
specified by
| |
| getResources | back to summary |
|---|---|
| public Enumeration Overrides java. Doc from java. Finds all the resources with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code. The name of a resource is a Resources in named modules are subject to the encapsulation rules
specified by
| |
| loadClass | back to summary |
|---|---|
| protected Class Overrides java. Doc from java. Loads the class with the specified binary name. The default implementation of this method searches for classes in the following order:
If the class was found using the above steps, and the
Subclasses of Unless overridden, this method synchronizes on the result of
| |
net.bytebuddy.dynamic.loading.MultipleParentClassLoader only if multiple or no
java.lang.ClassLoader s are found in the process. If exactly a single class loader is found,
this class loader is returned. All class loaders are applied in their collection order with the exception
of the bootstrap class loader which is represented by null and which is an implicit parent of any
class loader.
| Modifier and Type | Field and Description |
|---|---|
| private final List | classLoaders
The class loaders that were collected. |
| private final boolean | sealed
|
| Access | Constructor and Description |
|---|---|
| public | |
| public | Builder(boolean
true if the created class loader is sealed.Creates a new builder without any class loaders. |
| private | Builder(List<? extends ClassLoader>
The class loaders that were collected until now. classLoaders, boolean true if the created class loader is sealed.Creates a new builder. |
| Modifier and Type | Method and Description |
|---|---|
| public MultipleParentClassLoader. | |
| public MultipleParentClassLoader. | Returns: A new builder instance with the additional class loaders.The types of which to collect the class loaders. types)Appends the class loaders of the given types if those class loaders were not yet collected. |
| public MultipleParentClassLoader. | Returns: A new builder instance with the additional class loaders.The class loaders to be collected. classLoader)Appends the given class loaders if they were not yet collected. |
| public MultipleParentClassLoader. | Returns: A new builder instance with the additional class loaders.The class loaders to collected. classLoaders)Appends the given class loaders if they were not yet appended. |
| public MultipleParentClassLoader. | Returns: A new builder instance with the additional class loaders of the provided types if they were not yet collected.The types of which to collect the class loaders. type)Appends the class loaders of the given types but filters any duplicates within the hierarchy of class loaders. |
| public MultipleParentClassLoader. | Returns: A new builder instance with the additional class loaders.The types of which to collect the class loaders. types)Appends the class loaders of the given types but filters any duplicates within the hierarchy of class loaders. |
| public MultipleParentClassLoader. | Returns: A new builder instance with the additional class loaders.The class loaders to be collected. classLoader)Appends the given class loaders but removes any class loaders that are the parent of any previously registered class loader. |
| public MultipleParentClassLoader. | Returns: A new builder instance with the additional class loaders.The class loaders to collected. classLoaders)Appends the given class loaders but removes any class loaders that are the parent of any previously registered class loader. |
| public ClassLoader | Returns: A suitable class loader.Returns the only class loader that was appended if exactly one class loader was appended or a multiple parent class loader as a parent of all supplied class loader and with the bootstrap class loader as an implicit parent. |
| public ClassLoader | Returns: A suitable class loader.The class loader's contractual parent which is accessible via parent)ClassLoader#getParent(). If this class loader
is also included in the appended class loaders, it is notReturns the only class loader that was appended if exactly one class loader was appended or a multiple parent class loader as a parent of all supplied class loader and with the bootstrap class loader as an implicit parent. |
| private ClassLoader | Returns: A multiple parent class loader that includes all collected class loaders and the explicit parent.The explicit parent class loader. parent)Creates a multiple parent class loader with an explicit parent. |
| public MultipleParentClassLoader. | Returns: A builder that does not longer consider any appended class loaders that matched the provided matcher.The matcher to be used for filtering. matcher)Only retains all class loaders that match the given matcher. |
| classLoaders | back to summary |
|---|---|
| private final List<? extends ClassLoader> classLoaders The class loaders that were collected. | |
| sealed | back to summary |
|---|---|
| private final boolean sealed
| |
| Builder | back to summary |
|---|---|
| public Builder() Creates a new builder without any class loaders. | |
| Builder | back to summary |
|---|---|
| public Builder(boolean sealed) Creates a new builder without any class loaders.
| |
| Builder | back to summary |
|---|---|
| private Builder(List<? extends ClassLoader> classLoaders, boolean sealed) Creates a new builder.
| |
| append | back to summary |
|---|---|
| public MultipleParentClassLoader. Appends the class loaders of the given types. The bootstrap class loader is implicitly skipped as it is an implicit parent of any class loader.
| |
| append | back to summary |
|---|---|
| public MultipleParentClassLoader. Appends the class loaders of the given types if those class loaders were not yet collected. The bootstrap class loader is implicitly skipped as it is an implicit parent of any class loader.
| |
| append | back to summary |
|---|---|
| public MultipleParentClassLoader. Appends the given class loaders if they were not yet collected. The bootstrap class loader is implicitly skipped as it is an implicit parent of any class loader.
| |
| append | back to summary |
|---|---|
| public MultipleParentClassLoader. Appends the given class loaders if they were not yet appended. The bootstrap class loader is never appended as it is an implicit parent of any class loader.
| |
| appendMostSpecific | back to summary |
|---|---|
| public MultipleParentClassLoader. Appends the class loaders of the given types but filters any duplicates within the hierarchy of class loaders. The bootstrap class loader is implicitly skipped as it is an implicit parent of any class loader. Class loaders are prepended to the list of class loaders.
| |
| appendMostSpecific | back to summary |
|---|---|
| public MultipleParentClassLoader. Appends the class loaders of the given types but filters any duplicates within the hierarchy of class loaders. The bootstrap class loader is implicitly skipped as it is an implicit parent of any class loader. Class loaders are prepended to the list of class loaders.
| |
| appendMostSpecific | back to summary |
|---|---|
| public MultipleParentClassLoader. Appends the given class loaders but removes any class loaders that are the parent of any previously registered class loader. The bootstrap class loader is implicitly skipped as it is an implicit parent of any class loader.
| |
| appendMostSpecific | back to summary |
|---|---|
| public MultipleParentClassLoader. Appends the given class loaders but removes any class loaders that are the parent of any previously registered class loader. The bootstrap class loader is implicitly skipped as it is an implicit parent of any class loader.
| |
| build | back to summary |
|---|---|
| public ClassLoader build() Returns the only class loader that was appended if exactly one class loader was appended or a multiple parent class loader as a parent of all supplied class loader and with the bootstrap class loader as an implicit parent. If no class loader was appended, a new class loader is created that declares no parents. If a class loader is created, its explicit parent is set to be the bootstrap class loader. Important Note Byte Buddy does not provide any access control for the creation of the class loader. It is the responsibility of the user of this builder to provide such privileges.
| |
| build | back to summary |
|---|---|
| public ClassLoader build(ClassLoader parent) Returns the only class loader that was appended if exactly one class loader was appended or a multiple parent class loader as a parent of all supplied class loader and with the bootstrap class loader as an implicit parent. If no class loader was appended, or if only the supplied parent to this method was included, this class loader is returned, Important Note Byte Buddy does not provide any access control for the creation of the class loader. It is the responsibility of the user of this builder to provide such privileges.
| |
| doBuild | back to summary |
|---|---|
| private ClassLoader doBuild(ClassLoader parent) Creates a multiple parent class loader with an explicit parent.
| |
| filter | back to summary |
|---|---|
| public MultipleParentClassLoader. Only retains all class loaders that match the given matcher.
| |
| Modifier and Type | Field and Description |
|---|---|
| private Enumeration | current
The currently represented enumeration or |
| private final List | enumerations
The remaining lists of enumerations. |
| private static final int | FIRST
Indicates the first index of a list. |
| Access | Constructor and Description |
|---|---|
| protected | CompoundEnumeration(List<Enumeration<URL>>
The enumerations to represent. enumerations)Creates a compound enumeration. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | hasMoreElements()
Implements java. |
| public URL | nextElement()
Implements java. |
| current | back to summary |
|---|---|
| private Enumeration<URL> current The currently represented enumeration or | |
| enumerations | back to summary |
|---|---|
| private final List<Enumeration<URL>> enumerations The remaining lists of enumerations. | |
| FIRST | back to summary |
|---|---|
| private static final int FIRST Indicates the first index of a list. | |
| CompoundEnumeration | back to summary |
|---|---|
| protected CompoundEnumeration(List<Enumeration<URL>> enumerations) Creates a compound enumeration.
| |
| hasMoreElements | back to summary |
|---|---|
| public boolean hasMoreElements() Implements java. Doc from java. Tests if this enumeration contains more elements.
| |
| nextElement | back to summary |
|---|---|
| public URL nextElement() Implements java. Doc from java. Returns the next element of this enumeration if this enumeration object has at least one more element to provide.
| |