ModuleClassLoader
public abstract class ConcurrentClassLoader extends NamedClassLoader
Modifier and Type | Field | Description |
---|---|---|
protected static Enumeration<URL> |
EMPTY_ENUMERATION |
An empty enumeration, for subclasses to use if desired.
|
Modifier | Constructor | Description |
---|---|---|
protected |
ConcurrentClassLoader() |
Construct a new instance, using our class loader as the parent.
|
protected |
ConcurrentClassLoader(String name) |
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. |
protected |
ConcurrentClassLoader(ConcurrentClassLoader parent,
String name) |
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 | Description |
---|---|---|
protected Class<?> |
defineOrLoadClass(String className,
byte[] bytes,
int off,
int len) |
Atomically define or load the named class.
|
protected Class<?> |
defineOrLoadClass(String className,
byte[] bytes,
int off,
int len,
ProtectionDomain protectionDomain) |
Atomically define or load the named class.
|
protected Package |
definePackage(String name,
String specTitle,
String specVersion,
String specVendor,
String implTitle,
String implVersion,
String implVendor,
URL sealBase) |
Defines a package by name in this ConcurrentClassLoader.
|
protected Class<?> |
findClass(String className) |
Implementation of
ClassLoader.findClass(String) . |
protected Class<?> |
findClass(String className,
boolean exportsOnly,
boolean resolve) |
Find a class, possibly delegating to other loader(s).
|
protected Class<?> |
findClass(String moduleName,
String className) |
Implementation of
ClassLoader.findClass(String, String) . |
protected Package |
findLoadedPackage(String name) |
Load a package from this class loader only.
|
protected URL |
findResource(String name) |
Never used.
|
protected URL |
findResource(String name,
boolean exportsOnly) |
Find the resource with the given name and exported status.
|
protected URL |
findResource(String moduleName,
String name) |
Find the resource with the given name in specified java module.
|
protected InputStream |
findResourceAsStream(String name,
boolean exportsOnly) |
Finds the resource with the given name and exported status, returning the resource content as a stream.
|
protected Enumeration<URL> |
findResources(String name) |
Never used.
|
protected Enumeration<URL> |
findResources(String name,
boolean exportsOnly) |
Finds the resources with the given name and exported status.
|
protected Package |
getPackage(String name) |
Load a package which is visible to this class loader.
|
protected Package |
getPackageByName(String name) |
Perform the actual work to load a package which is visible to this class loader.
|
protected Package[] |
getPackages() |
Get all defined packages which are visible to this class loader.
|
URL |
getResource(String name) |
Finds the resource with the given name.
|
InputStream |
getResourceAsStream(String name) |
Returns an input stream for reading the specified resource.
|
Enumeration<URL> |
getResources(String name) |
Finds all available resources with the given name.
|
Class<?> |
loadClass(String className) |
Loads the class with the specified binary name.
|
Class<?> |
loadClass(String className,
boolean resolve) |
Loads the class with the specified binary name.
|
Class<?> |
loadExportedClass(String className) |
Same as
loadClass(String) , except only exported classes will be considered. |
Class<?> |
loadExportedClass(String className,
boolean resolve) |
Same as
loadClass(String,boolean) , except only exported classes will be considered. |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
getName
protected static final Enumeration<URL> EMPTY_ENUMERATION
protected ConcurrentClassLoader(ConcurrentClassLoader parent)
null
to create a root concurrent class loader.parent
- the parent class loaderprotected ConcurrentClassLoader()
protected ConcurrentClassLoader(ConcurrentClassLoader parent, String name)
null
to create a root concurrent class loader.parent
- the parent class loadername
- the name of this class loader, or null
if it is unnamedprotected ConcurrentClassLoader(String name)
name
- the name of this class loader, or null
if it is unnamedpublic final Class<?> loadClass(String className) throws ClassNotFoundException
loadClass(className, false)
.loadClass
in class ClassLoader
className
- The binary name of the classClass
instanceClassNotFoundException
- if the class was not foundpublic final Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException
loadClass
in class ClassLoader
className
- The binary name of the classresolve
- true
if the class should be linked after loadingClass
instanceClassNotFoundException
public final Class<?> loadExportedClass(String className) throws ClassNotFoundException
loadClass(String)
, except only exported classes will be considered.className
- the class nameClassNotFoundException
- if the class isn't foundpublic final Class<?> loadExportedClass(String className, boolean resolve) throws ClassNotFoundException
loadClass(String,boolean)
, except only exported classes will be considered.className
- the class nameresolve
- true
if the class should be linked after loadingClassNotFoundException
- if the class isn't foundprotected Class<?> findClass(String className, boolean exportsOnly, boolean resolve) throws 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 loadingClassNotFoundException
- if the class is not foundprotected final Class<?> defineOrLoadClass(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 Class<?> defineOrLoadClass(String className, byte[] bytes, int off, int len, 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 Class<?> findClass(String className) throws ClassNotFoundException
ClassLoader.findClass(String)
.findClass
in class ClassLoader
className
- the class namefindClass(className, false, false)
ClassNotFoundException
protected final Class<?> findClass(String moduleName, String className)
ClassLoader.findClass(String, String)
.findClass
in class ClassLoader
moduleName
- the Java module nameclassName
- the class namefindClass(className, false, false)
public final URL getResource(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 ClassLoader
name
- the name of the resourcenull
if no such resource exists or the invoker does not have adequate
permission to access itpublic final Enumeration<URL> getResources(String name) throws IOException
getResources
in class ClassLoader
name
- the resource nameIOException
- if an I/O error occursgetResource(String)
protected URL findResource(String name, boolean exportsOnly)
name
- the resource nameexportsOnly
- true
to consider only exported resources or false
to consider all resourcesgetResource(String)
protected final URL findResource(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 ClassLoader
name
- ignorednull
alwaysprotected final URL findResource(String moduleName, String name) throws IOException
findResource
in class ClassLoader
moduleName
- java module namename
- the resource nameIOException
getResource(String)
protected Enumeration<URL> findResources(String name, boolean exportsOnly) throws IOException
name
- the resource nameexportsOnly
- true
to consider only exported resources or false
to consider all resourcesIOException
- if an I/O error occursgetResources(String)
protected final Enumeration<URL> findResources(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 ClassLoader
name
- ignoredprotected InputStream findResourceAsStream(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 InputStream getResourceAsStream(String name)
findResourceAsStream(String, boolean)
.getResourceAsStream
in class ClassLoader
name
- the resource namenull
if the resource is not foundprotected final Package getPackage(String name)
getPackage
in class ClassLoader
name
- the package namenull
if no such package is visible to this class loaderprotected Package getPackageByName(String name)
name
- the package namenull
if no such package is visible to this class loaderprotected Package[] getPackages()
getPackages
in class ClassLoader
protected final Package findLoadedPackage(String name)
name
- the package namenull
if no such package is defined by this class loaderprotected Package definePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase) throws IllegalArgumentException
definePackage
in class 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 URLIllegalArgumentException
Copyright © 2018 JBoss by Red Hat. All rights reserved.