Package sonia.scm.net
Class ChildFirstURLClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
sonia.scm.net.ChildFirstURLClassLoader
- All Implemented Interfaces:
Closeable
,AutoCloseable
The ChildFirstURLClassLoader alters regular ClassLoader delegation and will
check the URLs used in its initialization for matching classes before
delegating to its parent. Sometimes also referred to as a
ParentLastClassLoader.
- Since:
- 1.29
-
Constructor Summary
ConstructorsConstructorDescriptionChildFirstURLClassLoader
(URL[] urls) Constructs a new ChildFirstURLClassLoader for the specified URLs using the default delegation parent ClassLoader.ChildFirstURLClassLoader
(URL[] urls, ClassLoader parent) Constructs a new ChildFirstURLClassLoader for the specified URLs using the given parent ClassLoader for delegation.ChildFirstURLClassLoader
(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) Constructs a new URLClassLoader for the specified URLs, parent class loader, and URLStreamHandlerFactory. -
Method Summary
Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
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, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
ChildFirstURLClassLoader
Constructs a new ChildFirstURLClassLoader for the specified URLs using the default delegation parent ClassLoader.- Parameters:
urls
- the URLs from which to load classes and resources
-
ChildFirstURLClassLoader
Constructs a new ChildFirstURLClassLoader for the specified URLs using the given parent ClassLoader for delegation.- Parameters:
urls
- the URLs from which to load classes and resourcesparent
- the parent class loader for delegation
-
ChildFirstURLClassLoader
Constructs a new URLClassLoader for the specified URLs, parent class loader, and URLStreamHandlerFactory. The parent argument will be used as the parent class loader for delegation. The factory argument will be used as the stream handler factory to obtain protocol handlers when creating new URLs.- Parameters:
urls
- the URLs from which to load classes and resourcesparent
- the parent class loader for delegationfactory
- the URLStreamHandlerFactory to use when creating URLs
-
-
Method Details
-
loadClass
Loads the class with the specified name. The default implementation of this method searches for classes in the following order:
-
Invoke the
ClassLoader.findClass(String)
method to find the class. -
Invoke
ClassLoader.findLoadedClass(String)
to check if the class has already been loaded. -
Invoke the
ClassLoader.loadClass(String)
method on the parent class loader. If the parent is null the class loader built-in to the virtual machine is used, instead.
resolve
flag is true, this method will then invoke theClassLoader.resolveClass(Class)
method on the resulting Class object. Subclasses of ClassLoader are encouraged to overrideClassLoader.findClass(String)
, rather than this method.- Overrides:
loadClass
in classClassLoader
- Parameters:
name
- the name of the classresolve
- if true then resolve the class- Returns:
- the resulting
Class
object - Throws:
ClassNotFoundException
- if the class could not be found
-
Invoke the
-
getResource
- Overrides:
getResource
in classClassLoader
-