public abstract class ConcurrentClassLoader
extends java.lang.ClassLoader
Modifier and Type | Field and Description |
---|---|
private static java.lang.ClassLoader |
definingLoader |
protected static java.util.Enumeration<java.net.URL> |
EMPTY_ENUMERATION
An empty enumeration, for subclasses to use if desired.
|
private static java.lang.ThreadLocal<java.lang.Boolean> |
GET_PACKAGE_SUPPRESSOR |
private UnlockedReadHashMap<java.lang.String,java.lang.Package> |
packages |
Modifier | Constructor and Description |
---|---|
protected |
ConcurrentClassLoader()
Construct a new instance, using our class loader as the parent.
|
protected |
ConcurrentClassLoader(ConcurrentClassLoader parent)
Construct a new instance with the given parent class loader, which must be a concurrent class loader, or
null
to create a root concurrent class loader. |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Class<?> |
defineOrLoadClass(java.lang.String className,
byte[] bytes,
int off,
int len)
Atomically define or load the named class.
|
protected java.lang.Class<?> |
defineOrLoadClass(java.lang.String className,
byte[] bytes,
int off,
int len,
java.security.ProtectionDomain protectionDomain)
Atomically define or load the named class.
|
protected java.lang.Package |
definePackage(java.lang.String name,
java.lang.String specTitle,
java.lang.String specVersion,
java.lang.String specVendor,
java.lang.String implTitle,
java.lang.String implVersion,
java.lang.String implVendor,
java.net.URL sealBase)
Defines a package by name in this ConcurrentClassLoader.
|
protected java.lang.Class<?> |
findClass(java.lang.String className)
Implementation of
ClassLoader.findClass(String) . |
protected java.lang.Class<?> |
findClass(java.lang.String className,
boolean exportsOnly,
boolean resolve)
Find a class, possibly delegating to other loader(s).
|
protected java.lang.Package |
findLoadedPackage(java.lang.String name)
Load a package from this class loader only.
|
protected java.net.URL |
findResource(java.lang.String name)
Never used.
|
protected java.net.URL |
findResource(java.lang.String name,
boolean exportsOnly)
Find the resource with the given name and exported status.
|
protected java.io.InputStream |
findResourceAsStream(java.lang.String name,
boolean exportsOnly)
Finds the resource with the given name and exported status, returning the resource content as a stream.
|
protected java.util.Enumeration<java.net.URL> |
findResources(java.lang.String name)
Never used.
|
protected java.util.Enumeration<java.net.URL> |
findResources(java.lang.String name,
boolean exportsOnly)
Finds the resources with the given name and exported status.
|
protected java.lang.Package |
getPackage(java.lang.String name)
Load a package which is visible to this class loader.
|
protected java.lang.Package |
getPackageByName(java.lang.String name)
Perform the actual work to load a package which is visible to this class loader.
|
protected java.lang.Package[] |
getPackages()
Get all defined packages which are visible to this class loader.
|
java.net.URL |
getResource(java.lang.String name)
Finds the resource with the given name.
|
java.io.InputStream |
getResourceAsStream(java.lang.String name)
Returns an input stream for reading the specified resource.
|
java.util.Enumeration<java.net.URL> |
getResources(java.lang.String name)
Finds all available resources with the given name.
|
java.lang.Class<?> |
loadClass(java.lang.String className)
Loads the class with the specified binary name.
|
java.lang.Class<?> |
loadClass(java.lang.String className,
boolean resolve)
Loads the class with the specified binary name.
|
java.lang.Class<?> |
loadExportedClass(java.lang.String className)
Same as
loadClass(String) , except only exported classes will be considered. |
java.lang.Class<?> |
loadExportedClass(java.lang.String className,
boolean resolve)
Same as
loadClass(String,boolean) , except only exported classes will be considered. |
private java.lang.Class<?> |
performLoadClass(java.lang.String className,
boolean exportsOnly,
boolean resolve)
Perform a class load operation.
|
private java.lang.Class<?> |
performLoadClassUnchecked(java.lang.String className,
boolean exportsOnly,
boolean resolve) |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getParent, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
private static final java.lang.ClassLoader definingLoader
private static final java.lang.ThreadLocal<java.lang.Boolean> GET_PACKAGE_SUPPRESSOR
protected static final java.util.Enumeration<java.net.URL> EMPTY_ENUMERATION
private final UnlockedReadHashMap<java.lang.String,java.lang.Package> packages
protected ConcurrentClassLoader(ConcurrentClassLoader parent)
null
to create a root concurrent class loader.parent
- the parent class loaderprotected ConcurrentClassLoader()
public final java.lang.Class<?> loadClass(java.lang.String className) throws java.lang.ClassNotFoundException
loadClass(className, false)
.loadClass
in class java.lang.ClassLoader
className
- The binary name of the classClass
instancejava.lang.ClassNotFoundException
- if the class was not foundpublic final java.lang.Class<?> loadClass(java.lang.String className, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
className
- The binary name of the classresolve
- true
if the class should be linked after loadingClass
instancejava.lang.ClassNotFoundException
public final java.lang.Class<?> loadExportedClass(java.lang.String className) throws java.lang.ClassNotFoundException
loadClass(String)
, except only exported classes will be considered.className
- the class namejava.lang.ClassNotFoundException
- if the class isn't foundpublic final java.lang.Class<?> loadExportedClass(java.lang.String className, boolean resolve) throws java.lang.ClassNotFoundException
loadClass(String,boolean)
, except only exported classes will be considered.className
- the class nameresolve
- true
if the class should be linked after loadingjava.lang.ClassNotFoundException
- if the class isn't foundprotected java.lang.Class<?> findClass(java.lang.String className, boolean exportsOnly, boolean resolve) throws java.lang.ClassNotFoundException
ClassNotFoundException
.
If a class is to be defined by this method, it should be done via one of the atomic defineOrLoadClass
methods rather than defineClass()
in order to avoid spurious exceptions.
className
- the class nameexportsOnly
- true
if only exported classes should be consideredresolve
- true
if the class should be linked after loadingjava.lang.ClassNotFoundException
- if the class is not foundprotected final java.lang.Class<?> defineOrLoadClass(java.lang.String className, byte[] bytes, int off, int len)
className
- the class name to define or loadbytes
- the bytes to use to define the classoff
- the offset into the byte array at which the class bytes beginlen
- the number of bytes in the classprotected final java.lang.Class<?> defineOrLoadClass(java.lang.String className, byte[] bytes, int off, int len, java.security.ProtectionDomain protectionDomain)
className
- the class name to define or loadbytes
- the bytes to use to define the classoff
- the offset into the byte array at which the class bytes beginlen
- the number of bytes in the classprotectionDomain
- the protection domain for the defined classprotected final java.lang.Class<?> findClass(java.lang.String className) throws java.lang.ClassNotFoundException
ClassLoader.findClass(String)
.findClass
in class java.lang.ClassLoader
className
- the class namefindClass(className, false, false)
java.lang.ClassNotFoundException
public final java.net.URL getResource(java.lang.String name)
'/'
-separated path name that
identifies the resource. If the resource name starts with "java/"
then the parent class loader is used.
Otherwise, this method delegates to findResource(String, boolean)
.getResource
in class java.lang.ClassLoader
name
- the name of the resourcenull
if no such resource exists or the invoker does not have adequate
permission to access itpublic final java.util.Enumeration<java.net.URL> getResources(java.lang.String name) throws java.io.IOException
getResources
in class java.lang.ClassLoader
name
- the resource namejava.io.IOException
- if an I/O error occursgetResource(String)
protected java.net.URL findResource(java.lang.String name, boolean exportsOnly)
name
- the resource nameexportsOnly
- true
to consider only exported resources or false
to consider all resourcesgetResource(String)
protected final java.net.URL findResource(java.lang.String name)
ClassLoader.getResource(String)
and related methods can cause a loop condition
when this method is implemented; use findResource(String, boolean)
instead.findResource
in class java.lang.ClassLoader
name
- ignorednull
alwaysprotected java.util.Enumeration<java.net.URL> findResources(java.lang.String name, boolean exportsOnly) throws java.io.IOException
name
- the resource nameexportsOnly
- true
to consider only exported resources or false
to consider all resourcesjava.io.IOException
- if an I/O error occursgetResources(String)
protected final java.util.Enumeration<java.net.URL> findResources(java.lang.String name)
ClassLoader.getResources(String)
and related methods can cause a loop condition
when this method is implemented; use findResources(String, boolean)
instead. By default, returns
an empty enumeration.findResources
in class java.lang.ClassLoader
name
- ignoredprotected java.io.InputStream findResourceAsStream(java.lang.String name, boolean exportsOnly)
name
- the resource nameexportsOnly
- true
to consider only exported resources or false
to consider all resourcesnull
if the resource is not foundpublic final java.io.InputStream getResourceAsStream(java.lang.String name)
"java/"
, then
this method delegates to the parent class loader. Otherwise, this method delegates to findResourceAsStream(String, boolean)
.getResourceAsStream
in class java.lang.ClassLoader
name
- the resource namenull
if the resource is not foundprivate java.lang.Class<?> performLoadClass(java.lang.String className, boolean exportsOnly, boolean resolve) throws java.lang.ClassNotFoundException
findClass(String, boolean, boolean)
.className
- the class nameexportsOnly
- true
to consider only exported resources or false
to consider all resourcesresolve
- true
to resolve the loaded classfindClass(String, boolean, boolean)
java.lang.ClassNotFoundException
- if findClass(String, boolean, boolean)
throws this exceptionprivate java.lang.Class<?> performLoadClassUnchecked(java.lang.String className, boolean exportsOnly, boolean resolve) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
protected final java.lang.Package getPackage(java.lang.String name)
getPackage
in class java.lang.ClassLoader
name
- the package namenull
if no such package is visible to this class loaderprotected java.lang.Package getPackageByName(java.lang.String name)
name
- the package namenull
if no such package is visible to this class loaderprotected java.lang.Package[] getPackages()
getPackages
in class java.lang.ClassLoader
protected final java.lang.Package findLoadedPackage(java.lang.String name)
name
- the package namenull
if no such package is defined by this class loaderprotected java.lang.Package definePackage(java.lang.String name, java.lang.String specTitle, java.lang.String specVersion, java.lang.String specVendor, java.lang.String implTitle, java.lang.String implVersion, java.lang.String implVendor, java.net.URL sealBase) throws java.lang.IllegalArgumentException
definePackage
in class java.lang.ClassLoader
name
- the package namespecTitle
- the specification titlespecVersion
- the specification versionspecVendor
- the specification vendorimplTitle
- the implementation titleimplVersion
- the implementation versionimplVendor
- the implementation vendorsealBase
- if not null
, then this package is sealed with respect to the given code source URLjava.lang.IllegalArgumentException