public class ModuleClassLoader extends ConcurrentClassLoader
Module
, which has API methods to access the exported view of classes and resources.Modifier and Type | Class | Description |
---|---|---|
static class |
ModuleClassLoader.Configuration |
An opaque configuration used internally to create a module class loader.
|
EMPTY_ENUMERATION
Modifier | Constructor | Description |
---|---|---|
protected |
ModuleClassLoader(ModuleClassLoader.Configuration configuration) |
Construct a new instance.
|
Modifier and Type | Method | Description |
---|---|---|
void |
clearAssertionStatus() |
|
protected Object |
clone() |
|
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.
|
boolean |
equals(Object obj) |
|
protected void |
finalize() |
|
protected Class<?> |
findClass(String className,
boolean exportsOnly,
boolean resolve) |
Find a class, possibly delegating to other loader(s).
|
protected String |
findLibrary(String libname) |
Find a library from one of the resource loaders.
|
URL |
findResource(String name,
boolean exportsOnly) |
Find the resource with the given name and exported status.
|
InputStream |
findResourceAsStream(String name,
boolean exportsOnly) |
Finds the resource with the given name and exported status, returning the resource content as a stream.
|
Enumeration<URL> |
findResources(String name,
boolean exportsOnly) |
Finds the resources with the given name and exported status.
|
protected String |
getClassNotFoundExceptionMessage(String className,
Module fromModule) |
Returns an exception message used when producing instances of ClassNotFoundException.
|
Set<String> |
getLocalPaths() |
Get the (unmodifiable) set of paths which are locally available in this module class loader.
|
Module |
getModule() |
Get the module for this class loader.
|
String |
getName() |
Get the name of this module.
|
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.
|
int |
hashCode() |
|
Iterator<Resource> |
iterateResources(String startName,
boolean recurse) |
Iterate the resources within this module class loader.
|
Class<?> |
loadClassLocal(String className) |
Load a class from this class loader.
|
Class<?> |
loadClassLocal(String className,
boolean resolve) |
Load a local class from this class loader.
|
List<Resource> |
loadResourceLocal(String name) |
Load a local exported resource from this class loader.
|
protected void |
postDefine(ClassSpec classSpec,
Class<?> definedClass) |
A hook which is invoked after a class is defined.
|
protected void |
preDefine(ClassSpec classSpec,
String className) |
A hook which is invoked before a class is defined.
|
void |
setClassAssertionStatus(String className,
boolean enabled) |
|
void |
setDefaultAssertionStatus(boolean enabled) |
|
void |
setPackageAssertionStatus(String packageName,
boolean enabled) |
|
String |
toString() |
Get a string representation of this class loader.
|
defineClass, defineClass, defineClass, defineClass, findLoadedClass, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setSigners
defineOrLoadClass, defineOrLoadClass, findClass, findClass, findLoadedPackage, findResource, findResource, findResources, getPackage, getResource, getResourceAsStream, getResources, loadClass, loadClass, loadExportedClass, loadExportedClass
protected ModuleClassLoader(ModuleClassLoader.Configuration configuration)
configuration
- the module class loader configuration to useprotected final 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.
findClass
in class ConcurrentClassLoader
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 String getClassNotFoundExceptionMessage(String className, Module fromModule)
className
- the name of the class which is missingfromModule
- the module from which the class could not be foundpublic Class<?> loadClassLocal(String className) throws ClassNotFoundException
className
- the class name to loadnull
if it was not foundClassNotFoundException
- if an exception occurs while loading the class or its dependenciespublic Class<?> loadClassLocal(String className, boolean resolve) throws ClassNotFoundException
className
- the class nameresolve
- true
to resolve the loaded classnull
if it was not foundClassNotFoundException
- if an error occurs while loading the classpublic List<Resource> loadResourceLocal(String name)
name
- the resource nameprotected void preDefine(ClassSpec classSpec, String className)
classSpec
- the class spec of the defined classclassName
- the class to be definedprotected void postDefine(ClassSpec classSpec, Class<?> definedClass)
classSpec
- the class spec of the defined classdefinedClass
- the class that was definedprotected final String findLibrary(String libname)
findLibrary
in class ClassLoader
libname
- the library namepublic final URL findResource(String name, boolean exportsOnly)
findResource
in class ConcurrentClassLoader
name
- the resource nameexportsOnly
- true
to consider only exported resources or false
to consider all resourcesConcurrentClassLoader.getResource(String)
public final Enumeration<URL> findResources(String name, boolean exportsOnly)
findResources
in class ConcurrentClassLoader
name
- the resource nameexportsOnly
- true
to consider only exported resources or false
to consider all resourcesConcurrentClassLoader.getResources(String)
public final InputStream findResourceAsStream(String name, boolean exportsOnly)
findResourceAsStream
in class ConcurrentClassLoader
name
- the resource nameexportsOnly
- true
to consider only exported resources or false
to consider all resourcesnull
if the resource is not foundpublic final Module getModule()
public final String getName()
getName
in class NamedClassLoader
public final String toString()
protected final Package definePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase) throws IllegalArgumentException
definePackage
in class ConcurrentClassLoader
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
protected final Package getPackageByName(String name)
getPackageByName
in class ConcurrentClassLoader
name
- the package namenull
if no such package is visible to this class loaderprotected final Package[] getPackages()
getPackages
in class ConcurrentClassLoader
public final void setDefaultAssertionStatus(boolean enabled)
setDefaultAssertionStatus
in class ClassLoader
public final void setPackageAssertionStatus(String packageName, boolean enabled)
setPackageAssertionStatus
in class ClassLoader
public final void setClassAssertionStatus(String className, boolean enabled)
setClassAssertionStatus
in class ClassLoader
public final void clearAssertionStatus()
clearAssertionStatus
in class ClassLoader
protected final Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
protected final void finalize() throws Throwable
public final Iterator<Resource> iterateResources(String startName, boolean recurse)
startName
- the directory name to searchrecurse
- true
to recurse into subdirectories, false
otherwisepublic final Set<String> getLocalPaths()
Copyright © 2018 JBoss by Red Hat. All rights reserved.