java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
org.elasticsearch.plugins.UberModuleClassLoader
- All Implemented Interfaces:
AutoCloseable
This classloader will load classes from non-modularized sets of jars.
A synthetic module will be created for all jars in the bundle. We want
to be able to construct the read relationships in the module graph for this
synthetic module, which will make it different from the unnamed (classpath)
module.
Internally, we can delegate to a URLClassLoader, which is battle-tested when it comes to reading classes out of jars.
This classloader needs to avoid parent-first search: we'll check classes against a list of packages in this synthetic module, and load a class directly if it's part of this synthetic module. This will keep libraries from clashing.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected Class<?>
protected Class<?>
protected URL
findResource
(String name) This classloader does not restrict access to resources in its jars.protected URL
findResource
(String moduleName, String name) This classloader does not restrict access to resources in its jars.protected Enumeration<URL>
findResources
(String name) This classloader does not restrict access to resources in its jars.protected Class<?>
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass, getPermissions
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Method Details
-
findClass
- Overrides:
findClass
in classClassLoader
- Parameters:
moduleName
- The module name; ornull
to find the class in the unnamed module for this class loadername
- The binary name of the class- Returns:
-
findClass
- Overrides:
findClass
in classClassLoader
- Parameters:
name
- The binary name of the class- Returns:
-
findResource
This classloader does not restrict access to resources in its jars. Users should expect the same behavior as that provided byURLClassLoader
.- Overrides:
findResource
in classClassLoader
- Parameters:
moduleName
- Name of this classloader's synthetic modulename
- The resource name- Returns:
- a URL for the resource, or null if the resource could not be found, if the module name does not match, or if the loader is closed.
-
findResource
This classloader does not restrict access to resources in its jars. Users should expect the same behavior as that provided byURLClassLoader
.- Overrides:
findResource
in classClassLoader
- Parameters:
name
- The resource name- Returns:
- a URL for the resource, or null if the resource could not be found, or if the loader is closed.
-
findResources
This classloader does not restrict access to resources in its jars. Users should expect the same behavior as that provided byURLClassLoader
.- Overrides:
findResources
in classClassLoader
- Parameters:
name
- The resource name- Returns:
- an Enumeration of URLs. If the loader is closed, the Enumeration contains no elements.
- Throws:
IOException
-
loadClass
- Overrides:
loadClass
in classClassLoader
- Throws:
ClassNotFoundException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-