This classloader forwards class loading and resource retrieval requests to the enclosed classloader references.
This classloader can be used when a parent classloader is required that provides access to multiple separate classloaders. This is often useful when multiple classpaths are loaded from different sources and a newly loaded classpath entity needs access to more already loaded classpaths.
This class is subclassable, but generally is not recommended. Users can use one of the static create(
protected final Collection< | The collection of classloaders which are used by this classloader. |
protected | MultiClassLoader( Creates a new instance that has the argument parent classloader, and the specified classloaders. |
protected | MultiClassLoader( Delegates to MultiClassLoader( null parent classloader. |
public static ClassLoader | create( Gets a classloader which loads classes using the argument classloaders. |
public static ClassLoader | create( Gets a classloader which loads classes using the argument classloaders. |
protected Class< | Finds the class with the specified binary name. |
protected URL | findResource( Finds the resource with the given name. |
protected Enumeration< | findResources( Returns an enumeration of URL objects representing all the resources with the given
name. |
public InputStream | getResourceAsStream( Returns an input stream for reading the specified resource. |
public static Set< | reduceClassLoaders( Reduces the argument classloaders to its smallest set that doesn't contain duplicate parent classloaders. |
public String | toString() Returns a string representation of the object. |
Immutable collection.
null
parent classloader.
The classloaders will be reduced according to the rules of reduceClassLoaders(
The returned classloader might not be an instance of MultiClassLoader. This can be the case when the
argument collection is empty, or contains a single item and the parent is null
.
null
.
The classloaders will be reduced according to the rules of reduceClassLoaders(
The null
classloader will be used as a parent classloader for the newly created classloader. That is
the bootstrap classloader, and not the system classloader.
Unlike the constructor ClassLoader.ClassLoader(), which has the system classloader as its parent, the returned classloader will have the bootstrap classloader instead.
null
.
The search order is described in the documentation for ClassLoader.getResource(
All classloaders will be part of the result set, unless:
- It is
null
.null
classloader represents the bootstrap classloader, which is always accessible. - A classloader is already present as a parent of an other classloader. E.g. If P is the parent of C, then if the set of [P, C, X] is reduced, the result will only be [C, X], as P is already accessible via C.
null
if the argument is null
.toString
method returns a string that
"textually represents" this object. The result should be a concise but informative representation that is easy
for a person to read. It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of
which the object is an instance, the at-sign character `@
', and the unsigned hexadecimal representation
of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())