Class HierarchyClassLoader
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
MinestomExtensionClassLoader,MinestomRootClassLoader
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<MinestomExtensionClassLoader> protected final List<HierarchyClassLoader> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(@NotNull MinestomExtensionClassLoader loader) findLibrary(String libname) getName()@Nullable InputStreamgetResourceAsStreamWithChildren(@NotNull String name) Finds a resource under the given name within this classloader, or if that fails, in any of its children.@Nullable URLgetResourceAsURLWithChildren(@NotNull String name) Finds a resource under the given name within this classloader, or if that fails, in any of its children.voidMethods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class java.security.SecureClassLoader
defineClass, defineClassMethods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
children
-
parents
-
-
Constructor Details
-
HierarchyClassLoader
-
-
Method Details
-
addChild
-
findLibrary
- Overrides:
findLibraryin classClassLoader
-
getResourceAsStreamWithChildren
@Nullable public @Nullable InputStream getResourceAsStreamWithChildren(@NotNull @NotNull String name) Finds a resource under the given name within this classloader, or if that fails, in any of its children. If the resource is found, the resource is opened as anInputStream, otherwisenullis returned.This method distinguishes itself from
URLClassLoader.getResourceAsStream(String), which will first query the parent classloader and only then this classloader. Further,URLClassLoader.getResourceAsStream(String)does not query children classloaders.When failing to open a resource using
URL.openStream(), the resource is deemed to no exist in this classloader and will search in children classloaders.The
InputStreamreturned by this method must be closed manually, it is unspecified whether the returned object will be closed whenever this classloader is closed. A warning will be logged in that circumstance.- Parameters:
name- The pathname of the resource. SeeURLClassLoader.findResource(String).- Returns:
- The
InputStreamof the corresponding found resource, or null if such a resource does not exist. - Since:
- 0.0.1
- Implementation Note:
- Search occurs depth-first, which means that registration order can matter quite a lot.
-
getResourceAsURLWithChildren
@Nullable @AvailableSince("4.0.0-a20241006") public @Nullable URL getResourceAsURLWithChildren(@NotNull @NotNull String name) Finds a resource under the given name within this classloader, or if that fails, in any of its children. If the resource is found, the resource is returned as an URL, otherwisenullis returned.This method distinguishes itself from
ClassLoader.getResource(String), which will first query the parent classloader and only then this classloader. Further,ClassLoader.getResource(String)does not query children classloaders.- Parameters:
name- The pathname of the resource.- Returns:
- The
URLof the corresponding found resource, or null if such a resource does not exist. - Since:
- 4.0.0-a20241006
- Implementation Note:
- Search occurs depth-first, which means that registration order can matter quite a lot.
-
removeChildInHierarchy
-
getName
- Overrides:
getNamein classClassLoader
-