public abstract class ClassLoader extends Object
Modifier | Constructor and Description |
---|---|
protected |
ClassLoader()
Constructs a new instance of this class with the system
class loader as its parent.
|
protected |
ClassLoader(ClassLoader parentLoader)
Constructs a new instance of this class with the given
class loader as its parent.
|
Modifier and Type | Method and Description |
---|---|
void |
clearAssertionStatus()
Clears the default, package and class assertion status of a classloader
|
protected Object |
clone()
Answers a new instance of the same class as the receiver,
whose slots have been filled in with the values in the
slots of the receiver.
|
protected Class<?> |
defineClass(byte[] classRep,
int offset,
int length)
Deprecated.
Use defineClass(String, byte[], int, int)
|
protected Class<?> |
defineClass(String className,
byte[] classRep,
int offset,
int length)
Constructs a new class from an array of bytes containing a
class definition in class file format.
|
protected Class<?> |
defineClass(String className,
byte[] classRep,
int offset,
int length,
ProtectionDomain protectionDomain)
Constructs a new class from an array of bytes containing a
class definition in class file format and assigns the new
class to the specified protection domain.
|
protected Class<?> |
defineClass(String name,
ByteBuffer buffer,
ProtectionDomain domain)
Constructs a new class from an array of bytes containing a
class definition in class file format and assigns the new
class to the specified protection domain.
|
protected Package |
definePackage(String name,
String specTitle,
String specVersion,
String specVendor,
String implTitle,
String implVersion,
String implVendor,
URL sealBase)
Define a new Package using the specified information.
|
protected Class<?> |
findClass(String className)
Overridden by subclasses, by default throws ClassNotFoundException.
|
protected String |
findLibrary(String libName)
Answers the absolute path of the file containing the library
associated with the given name, or null.
|
protected Class<?> |
findLoadedClass(String className)
Attempts to find and return a class which has already
been loaded by the virtual machine.
|
protected URL |
findResource(String resName)
Answers an URL which can be used to access the resource
described by resName, using the class loader's resource lookup
algorithm.
|
protected Enumeration<URL> |
findResources(String resName)
Answers an Enumeration of URL which can be used to access the resources
described by resName, using the class loader's resource lookup
algorithm.
|
protected Class<?> |
findSystemClass(String className)
Attempts to load a class using the system class loader.
|
protected Object |
getClassLoadingLock(String className)
Answers the lock object for class loading in parallel.
|
protected Package |
getPackage(String name)
Attempt to locate the requested package.
|
protected Package[] |
getPackages()
Answers all the packages known to this class loader.
|
ClassLoader |
getParent()
Returns the specified ClassLoader's parent.
|
URL |
getResource(String resName)
Answers an URL which can be used to access the resource
described by resName, using the class loader's resource lookup
algorithm.
|
InputStream |
getResourceAsStream(String resName)
Answers a stream on a resource found by looking up
resName using the class loader's resource lookup
algorithm.
|
Enumeration<URL> |
getResources(String resName)
Answers an Enumeration of URL which can be used to access the resources
described by resName, using the class loader's resource lookup
algorithm.
|
static ClassLoader |
getSystemClassLoader()
Convenience operation to obtain a reference to the system class loader.
|
static URL |
getSystemResource(String resName)
Answers an URL specifying a resource which can be found by
looking up resName using the system class loader's resource
lookup algorithm.
|
static InputStream |
getSystemResourceAsStream(String resName)
Answers a stream on a resource found by looking up
resName using the system class loader's resource lookup
algorithm.
|
static Enumeration<URL> |
getSystemResources(String resName)
Answers an Enumeration of URL containing all resources which can be
found by looking up resName using the system class loader's resource
lookup algorithm.
|
Class<?> |
loadClass(String className)
Invoked by the Virtual Machine when resolving class references.
|
protected Class<?> |
loadClass(String className,
boolean resolveClass)
Attempts to load the type
className in the running VM,
optionally linking the type after a successful load. |
protected static boolean |
registerAsParallelCapable()
Attempts to register the ClassLoader as being capable of
parallel class loading.
|
protected void |
resolveClass(Class<?> clazz)
Forces a class to be linked (initialized).
|
void |
setClassAssertionStatus(String cname,
boolean enable)
Sets the assertion status of a class.
|
void |
setDefaultAssertionStatus(boolean enable)
Sets the default assertion status of a classloader
|
void |
setPackageAssertionStatus(String pname,
boolean enable)
Sets the assertion status of a package.
|
protected void |
setSigners(Class<?> c,
Object[] signers)
Sets the signers of a class.
|
protected ClassLoader()
SecurityException
- if a security manager exists and it does not
allow the creation of new ClassLoaders.protected ClassLoader(ClassLoader parentLoader)
parentLoader
- ClassLoader
the ClassLoader to use as the new class
loaders parent.SecurityException
- if a security manager exists and it does not
allow the creation of new ClassLoaders.@Deprecated protected final Class<?> defineClass(byte[] classRep, int offset, int length) throws ClassFormatError
classRep
- byte[]
a memory image of a class file.offset
- int
the offset into the classRep.length
- int
the length of the class file.ClassFormatError
- when the bytes are invalidprotected final Class<?> defineClass(String className, byte[] classRep, int offset, int length) throws ClassFormatError
className
- java.lang.String
the name of the new classclassRep
- byte[]
a memory image of a class fileoffset
- int
the offset into the classReplength
- int
the length of the class fileClassFormatError
- when the bytes are invalidprotected final Class<?> defineClass(String className, byte[] classRep, int offset, int length, ProtectionDomain protectionDomain) throws ClassFormatError
className
- java.lang.String
the name of the new class.classRep
- byte[]
a memory image of a class file.offset
- int
the offset into the classRep.length
- int
the length of the class file.protectionDomain
- ProtectionDomain
the protection domain this class should
belong to.ClassFormatError
- when the bytes are invalidprotected Class<?> findClass(String className) throws ClassNotFoundException
className
- String
the name of the class to search for.ClassNotFoundException
- always, unless overridden.protected final Class<?> findLoadedClass(String className)
className
- String
the name of the class to search for.protected final Class<?> findSystemClass(String className) throws ClassNotFoundException
className
- String
the name of the class to search for.ClassNotFoundException
- if the class can not be found.public final ClassLoader getParent()
SecurityException
- if a security manager exists and it does not
allow the parent loader to be retrieved.public URL getResource(String resName)
resName
- String
the name of the resource to find.Class.getResource(java.lang.String)
public Enumeration<URL> getResources(String resName) throws IOException
resName
- String
the name of the resource to find.IOException
- when an error occurspublic InputStream getResourceAsStream(String resName)
resName
- String
the name of the resource to find.Class.getResourceAsStream(java.lang.String)
public static ClassLoader getSystemClassLoader()
ClassLoader
objects created in the course of an application and will normally be the
same ClassLoader
as that used to launch an application.SecurityException
- if a security manager exists and it does not permit the
caller to access the system class loader.public static URL getSystemResource(String resName)
resName
- String
the name of the resource to find.Class.getResource(java.lang.String)
public static Enumeration<URL> getSystemResources(String resName) throws IOException
resName
- String
the name of the resource to find.IOException
- when an error occurspublic static InputStream getSystemResourceAsStream(String resName)
resName
- the name of the resource to find.Class.getResourceAsStream(java.lang.String)
public Class<?> loadClass(String className) throws ClassNotFoundException
className
- String
the name of the class to search for.ClassNotFoundException
- If the class could not be found.protected Class<?> loadClass(String className, boolean resolveClass) throws ClassNotFoundException
className
in the running VM,
optionally linking the type after a successful load.className
- String
the name of the class to search for.resolveClass
- boolean
indicates if class should be resolved after loading.ClassNotFoundException
- If the class could not be found.protected static boolean registerAsParallelCapable()
ClassLoader
protected Object getClassLoadingLock(String className)
className
- String
name of the to be loaded classNullPointerException
- if registered as parallel capable and className is nullClassLoader
protected final void resolveClass(Class<?> clazz)
clazz
- Class
the Class to link.NullPointerException
- if clazz is null.Class.getResource(java.lang.String)
protected URL findResource(String resName)
resName
- String
the name of the resource to find.protected Enumeration<URL> findResources(String resName) throws IOException
resName
- String
the name of the resource to find.IOException
- when an error occursprotected String findLibrary(String libName)
libName
- String
the name of the library to find.protected Package getPackage(String name)
name
- The name of the package to findprotected Package[] getPackages()
protected Package definePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase) throws IllegalArgumentException
name
- The name of the packagespecTitle
- The title of the specification for the PackagespecVersion
- The version of the specification for the PackagespecVendor
- The vendor of the specification for the PackageimplTitle
- The implementation title of the PackageimplVersion
- The implementation version of the PackageimplVendor
- The specification vendor of the PackagesealBase
- The URL used to seal the Package, if null the Package is not sealedIllegalArgumentException
- if the Package already existsprotected final void setSigners(Class<?> c, Object[] signers)
c
- The Class objectsigners
- The signers for the classpublic void setClassAssertionStatus(String cname, boolean enable)
cname
- Class nameenable
- Enable or disable assertionpublic void setPackageAssertionStatus(String pname, boolean enable)
pname
- Package nameenable
- Enable or disable assertionpublic void setDefaultAssertionStatus(boolean enable)
enable
- Enable or disable assertionpublic void clearAssertionStatus()
protected final Class<?> defineClass(String name, ByteBuffer buffer, ProtectionDomain domain) throws ClassFormatError
name
- java.lang.String
the name of the new class.buffer
- a memory image of a class file.domain
- the protection domain this class should
belong to.ClassFormatError
- when the bytes are invalidprotected Object clone() throws CloneNotSupportedException
Object
Classes which wish to support cloning must specify that they implement the Cloneable interface, since the native implementation checks for this.
clone
in class Object
CloneNotSupportedException
- if the receiver's class does not implement
the interface Cloneable.Eclipse OpenJ9 website.
To raise a bug report or suggest an improvement create an Eclipse OpenJ9 issue.
Copyright © 1993, 2023 IBM Corp. and others.