This class must be implemented by the VM. The documented methods and natives must be implemented to support other provided class implementations in this package.
Public Member Functions | |
final 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. | |
Enumeration< URL > | getResources (String resName) throws IOException |
Answers an Enumeration of URL which can be used to access the resources 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. | |
Class<?> | loadClass (String className) throws ClassNotFoundException |
Invoked by the Virtual Machine when resolving class references. | |
void | setClassAssertionStatus (String cname, boolean enable) |
Sets the assertion status of a class. | |
void | setPackageAssertionStatus (String pname, boolean enable) |
Sets the assertion status of a package. | |
void | setDefaultAssertionStatus (boolean enable) |
Sets the default assertion status of a classloader. | |
void | clearAssertionStatus () |
Clears the default, package and class assertion status of a classloader. | |
Static Public Member Functions | |
static ClassLoader | getSystemClassLoader () |
Returns 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 Enumeration< URL > | getSystemResources (String resName) throws IOException |
Answers an Enumeration of URLs containing all resources 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. | |
Protected Member Functions | |
ClassLoader () | |
Constructs a new instance of this class with the system class loader as its parent. | |
ClassLoader (ClassLoader parentLoader) | |
Constructs a new instance of this class with the given class loader as its parent. | |
final Class<?> | defineClass (byte[] classRep, int offset, int length) throws ClassFormatError |
Constructs a new class from an array of bytes containing a class definition in class file format. | |
final Class<?> | defineClass (String className, byte[] classRep, int offset, int length) throws ClassFormatError |
Constructs a new class from an array of bytes containing a class definition in class file format. | |
final Class<?> | defineClass (String className, byte[] classRep, int offset, int length, ProtectionDomain protectionDomain) throws java.lang.ClassFormatError |
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. | |
final Class<?> | defineClass (String name, ByteBuffer b, ProtectionDomain protectionDomain) throws ClassFormatError |
Class<?> | findClass (String className) throws ClassNotFoundException |
Overridden by subclasses, by default throws ClassNotFoundException. | |
final Class<?> | findLoadedClass (String className) |
Attempts to find and return a class which has already been loaded by the virtual machine. | |
final Class<?> | findSystemClass (String className) throws ClassNotFoundException |
Attempts to load a class using the system class loader. | |
Class<?> | loadClass (String className, boolean resolveClass) throws ClassNotFoundException |
Loads the class with the specified name, optionally linking the class after load. | |
final void | resolveClass (Class<?> clazz) |
Forces a class to be linked (initialized). | |
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. | |
Enumeration< URL > | findResources (String resName) throws IOException |
Answers an Enumeration of URL which can be used to access the resources described by resName, using the class loader's resource lookup algorithm. | |
String | findLibrary (String libName) |
Answers the absolute path of the file containing the library associated with the given name, or null. | |
Package | getPackage (String name) |
Attempt to locate the requested package. | |
Package[] | getPackages () |
Return all the packages known to this class loader. | |
Package | definePackage (String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase) throws IllegalArgumentException |
Define a new Package using the specified information. | |
final void | setSigners (Class<?> c, Object[] signers) |
Sets the signers of a class. | |
Package Functions | |
final boolean | isSystemClassLoader () |
This method must be provided by the VM vendor, as it is used by other provided class implementations in this package. | |
final boolean | isAncestorOf (ClassLoader child) |
final Object[] | getSigners (Class<?> c) |
Gets the signers of a class. | |
boolean | getClassAssertionStatus (String cname) |
Answers the assertion status of the named class Returns the assertion status of the class or nested class if it has been set. | |
boolean | getPackageAssertionStatus (String pname) |
Answers the assertion status of the named package Returns the assertion status of the named package or superpackage if that has been set. | |
boolean | getDefaultAssertionStatus () |
Answers the default assertion status. | |
Static Package Functions | |
static final void | initializeClassLoaders () |
static final ClassLoader | getStackClassLoader (int depth) |
static ClassLoader | callerClassLoader () |
This method must be included, as it is used by System.load(), System.loadLibrary(). | |
static void | loadLibraryWithClassLoader (String libName, ClassLoader loader) |
This method must be provided by the VM vendor, as it is called by java.lang.System.loadLibrary(). | |
static void | loadLibraryWithPath (String libName, ClassLoader loader, String libraryPath) |
This method must be provided by the VM vendor, as it is called by java.lang.System.load(). | |
Static Package Attributes | |
static ClassLoader | systemClassLoader |
The 'System' ClassLoader; also known as the bootstrap ClassLoader. |
java.lang.ClassLoader.ClassLoader | ( | ) | [protected] |
Constructs a new instance of this class with the system class loader as its parent.
SecurityException | if a security manager exists and it does not allow the creation of new ClassLoaders. |
java.lang.ClassLoader.ClassLoader | ( | ClassLoader | parentLoader | ) | [protected] |
Constructs a new instance of this class with the given class loader as its parent.
parentLoader | 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. | |
NullPointerException | if the parent is null. |
static final void java.lang.ClassLoader.initializeClassLoaders | ( | ) | [static, package] |
TODO Document this method.
static ClassLoader java.lang.ClassLoader.getSystemClassLoader | ( | ) | [static] |
Returns the system class loader.
This is the parent for new ClassLoader instances, and is typically the class loader used to start the application. If a security manager is present, and the caller's class loader is not null and the caller's class loader is not the same as or an ancestor of the system class loader, then this method calls the security manager's checkPermission method with a RuntimePermission("getClassLoader") permission to ensure it's ok to access the system class loader. If not, a SecurityException will be thrown.
SecurityException | if a security manager exists and it does not allow access to the system class loader. |
static URL java.lang.ClassLoader.getSystemResource | ( | String | resName | ) | [static] |
Answers an URL specifying a resource which can be found by looking up resName using the system class loader's resource lookup algorithm.
resName | The name of the resource to find. |
static Enumeration<URL> java.lang.ClassLoader.getSystemResources | ( | String | resName | ) | throws IOException [static] |
Answers an Enumeration of URLs containing all resources which can be found by looking up resName using the system class loader's resource lookup algorithm.
resName | String the name of the resource to find. |
IOException | if an IO exception occurs |
static InputStream java.lang.ClassLoader.getSystemResourceAsStream | ( | String | resName | ) | [static] |
Answers a stream on a resource found by looking up resName using the system class loader's resource lookup algorithm.
Basically, the contents of the java.class.path are searched in order, looking for a path which matches the specified resource.
resName | The name of the resource to find. |
final Class<?> java.lang.ClassLoader.defineClass | ( | byte[] | classRep, | |
int | offset, | |||
int | length | |||
) | throws ClassFormatError [protected] |
Constructs a new class from an array of bytes containing a class definition in class file format.
classRep | A memory image of a class file. | |
offset | The offset into the classRep. | |
length | The length of the class file. |
final Class<?> java.lang.ClassLoader.defineClass | ( | String | className, | |
byte[] | classRep, | |||
int | offset, | |||
int | length | |||
) | throws ClassFormatError [protected] |
Constructs a new class from an array of bytes containing a class definition in class file format.
className | The name of the new class | |
classRep | A memory image of a class file | |
offset | The offset into the classRep | |
length | The length of the class file |
final Class<?> java.lang.ClassLoader.defineClass | ( | String | className, | |
byte[] | classRep, | |||
int | offset, | |||
int | length, | |||
ProtectionDomain | protectionDomain | |||
) | throws java.lang.ClassFormatError [protected] |
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.
className | The name of the new class. | |
classRep | A memory image of a class file. | |
offset | The offset into the classRep. | |
length | The length of the class file. | |
protectionDomain | The protection domain this class should belongs to. |
final Class<?> java.lang.ClassLoader.defineClass | ( | String | name, | |
ByteBuffer | b, | |||
ProtectionDomain | protectionDomain | |||
) | throws ClassFormatError [protected] |
Defines a new class for the name, bytecodes in the byte buffer and the protection domain.
name | The name of the class to define. | |
b | The byte buffer containing the bytecodes of the new class. | |
protectionDomain | The protection domain this class belongs to. |
ClassFormatError | if an invalid class file is defined. |
Class<?> java.lang.ClassLoader.findClass | ( | String | className | ) | throws ClassNotFoundException [protected] |
Overridden by subclasses, by default throws ClassNotFoundException.
This method is called by loadClass() after the parent ClassLoader has failed to find a loaded class of the same name.
className | The name of the class to search for. |
ClassNotFoundException | if the class cannot be found. |
final Class<?> java.lang.ClassLoader.findLoadedClass | ( | String | className | ) | [protected] |
Attempts to find and return a class which has already been loaded by the virtual machine.
Note that the class may not have been linked and the caller should call resolveClass() on the result if necessary.
className | The name of the class to search for. |
final Class<?> java.lang.ClassLoader.findSystemClass | ( | String | className | ) | throws ClassNotFoundException [protected] |
Attempts to load a class using the system class loader.
Note that the class has already been been linked.
className | The name of the class to search for. |
ClassNotFoundException | if the class cannot be found. |
final ClassLoader java.lang.ClassLoader.getParent | ( | ) |
Returns the specified ClassLoader's parent.
SecurityException | if a security manager exists and it does not allow the parent loader to be retrieved. |
URL java.lang.ClassLoader.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.
The default behavior is just to return null.
resName | String the name of the resource to find. |
Enumeration<URL> java.lang.ClassLoader.getResources | ( | String | resName | ) | throws IOException |
Answers an Enumeration of URL which can be used to access the resources described by resName, using the class loader's resource lookup algorithm.
The default behavior is just to return an empty Enumeration.
resName | String the name of the resource to find. |
IOException | if an IO exception occurs |
InputStream java.lang.ClassLoader.getResourceAsStream | ( | String | resName | ) |
Answers a stream on a resource found by looking up resName using the class loader's resource lookup algorithm.
The default behavior is just to return null.
resName | String the name of the resource to find. |
Class<?> java.lang.ClassLoader.loadClass | ( | String | className | ) | throws ClassNotFoundException |
Invoked by the Virtual Machine when resolving class references.
Equivalent to loadClass(className, false);
className | The name of the class to search for. |
ClassNotFoundException | if the class could not be found. |
Class<?> java.lang.ClassLoader.loadClass | ( | String | className, | |
boolean | resolveClass | |||
) | throws ClassNotFoundException [protected] |
Loads the class with the specified name, optionally linking the class after load.
Steps are: 1) Call findLoadedClass(className) to determine if class is loaded 2) Call loadClass(className, resolveClass) on the parent loader. 3) Call findClass(className) to find the class
className | The name of the class to search for. | |
resolveClass | Indicates if class should be resolved after loading. |
ClassNotFoundException | if the class could not be found. |
final void java.lang.ClassLoader.resolveClass | ( | Class<?> | clazz | ) | [protected] |
Forces a class to be linked (initialized).
If the class has already been linked this operation has no effect.
clazz | The Class to link. |
NullPointerException | if clazz is null. |
final boolean java.lang.ClassLoader.isSystemClassLoader | ( | ) | [package] |
This method must be provided by the VM vendor, as it is used by other provided class implementations in this package.
A sample implementation of this method is provided by the reference implementation. This method is used by SecurityManager.classLoaderDepth(), currentClassLoader() and currentLoadedClass(). Answers true if the receiver is a system class loader.
Note that this method has package visibility only. It is defined here to avoid the security manager check in getSystemClassLoader, which would be required to implement this method anywhere else.
true
if the receiver is a system class loader final boolean java.lang.ClassLoader.isAncestorOf | ( | ClassLoader | child | ) | [package] |
Answers true if the receiver is ancestor of another class loader.
Note that this method has package visibility only. It is defined here to avoid the security manager check in getParent, which would be required to implement this method anywhere else.
child | A child candidate |
true
if the receiver is ancestor of the parameter URL java.lang.ClassLoader.findResource | ( | String | resName | ) | [protected] |
Answers an URL which can be used to access the resource described by resName, using the class loader's resource lookup algorithm.
The default behavior is just to return null. This should be implemented by a ClassLoader.
resName | The name of the resource to find. |
Enumeration<URL> java.lang.ClassLoader.findResources | ( | String | resName | ) | throws IOException [protected] |
Answers an Enumeration of URL which can be used to access the resources described by resName, using the class loader's resource lookup algorithm.
The default behavior is just to return an empty Enumeration.
resName | The name of the resource to find. |
IOException | when an error occurs |
String java.lang.ClassLoader.findLibrary | ( | String | libName | ) | [protected] |
Answers the absolute path of the file containing the library associated with the given name, or null.
If null is answered, the system searches the directories specified by the system property "java.library.path".
libName | The name of the library to find. |
Package java.lang.ClassLoader.getPackage | ( | String | name | ) | [protected] |
Attempt to locate the requested package.
If no package information can be located, null is returned.
name | The name of the package to find |
Package [] java.lang.ClassLoader.getPackages | ( | ) | [protected] |
Return all the packages known to this class loader.
Package java.lang.ClassLoader.definePackage | ( | String | name, | |
String | specTitle, | |||
String | specVersion, | |||
String | specVendor, | |||
String | implTitle, | |||
String | implVersion, | |||
String | implVendor, | |||
URL | sealBase | |||
) | throws IllegalArgumentException [protected] |
Define a new Package using the specified information.
name | The name of the package | |
specTitle | The title of the specification for the Package | |
specVersion | The version of the specification for the Package | |
specVendor | The vendor of the specification for the Package | |
implTitle | The implementation title of the Package | |
implVersion | The implementation version of the Package | |
implVendor | The specification vendor of the Package | |
sealBase | If sealBase is null, the package is left unsealed. Otherwise, the the package is sealed using this URL. |
IllegalArgumentException | if the Package already exists |
final Object [] java.lang.ClassLoader.getSigners | ( | Class<?> | c | ) | [package] |
Gets the signers of a class.
c | The Class object |
final void java.lang.ClassLoader.setSigners | ( | Class<?> | c, | |
Object[] | signers | |||
) | [protected] |
Sets the signers of a class.
c | The Class object | |
signers | The signers for the class |
static final ClassLoader java.lang.ClassLoader.getStackClassLoader | ( | int | depth | ) | [static, package] |
This must be provided by the VM vendor. It is used by SecurityManager.checkMemberAccess() with depth = 3. Note that checkMemberAccess() assumes the following stack when called:
< user code > <- want this class Class.getDeclared*(); Class.checkMemberAccess(); SecurityManager.checkMemberAccess(); <- current frame
Returns the ClassLoader of the method (including natives) at the specified depth on the stack of the calling thread. Frames representing the VM implementation of java.lang.reflect are not included in the list. Notes:
depth | the stack depth of the requested ClassLoader |
static ClassLoader java.lang.ClassLoader.callerClassLoader | ( | ) | [static, package] |
This method must be included, as it is used by System.load(), System.loadLibrary().
The reference implementation of this method uses the getStackClassLoader() method. Returns the ClassLoader of the method that called the caller. i.e. A.x() calls B.y() calls callerClassLoader(), A's ClassLoader will be returned. Returns null for the bootstrap ClassLoader.
static void java.lang.ClassLoader.loadLibraryWithClassLoader | ( | String | libName, | |
ClassLoader | loader | |||
) | [static, package] |
This method must be provided by the VM vendor, as it is called by java.lang.System.loadLibrary().
System.loadLibrary() cannot call Runtime.loadLibrary() because this method loads the library using the ClassLoader of the calling method. Loads and links the library specified by the argument.
libName | the name of the library to load | |
loader | the classloader in which to load the library |
UnsatisfiedLinkError | if the library could not be loaded | |
SecurityException | if the library was not allowed to be loaded |
static void java.lang.ClassLoader.loadLibraryWithPath | ( | String | libName, | |
ClassLoader | loader, | |||
String | libraryPath | |||
) | [static, package] |
This method must be provided by the VM vendor, as it is called by java.lang.System.load().
System.load() cannot call Runtime.load() because the library is loaded using the ClassLoader of the calling method. Loads and links the library specified by the argument. No security check is done.
libName | the name of the library to load | |
loader | the classloader in which to load the library | |
libraryPath | the library path to search, or null |
UnsatisfiedLinkError | if the library could not be loaded |
void java.lang.ClassLoader.setClassAssertionStatus | ( | String | cname, | |
boolean | enable | |||
) |
Sets the assertion status of a class.
cname | Class name | |
enable | Enable or disable assertion |
void java.lang.ClassLoader.setPackageAssertionStatus | ( | String | pname, | |
boolean | enable | |||
) |
Sets the assertion status of a package.
pname | Package name | |
enable | Enable or disable assertion |
void java.lang.ClassLoader.setDefaultAssertionStatus | ( | boolean | enable | ) |
Sets the default assertion status of a classloader.
enable | Enable or disable assertion |
void java.lang.ClassLoader.clearAssertionStatus | ( | ) |
Clears the default, package and class assertion status of a classloader.
boolean java.lang.ClassLoader.getClassAssertionStatus | ( | String | cname | ) | [package] |
Answers the assertion status of the named class Returns the assertion status of the class or nested class if it has been set.
Otherwise returns the assertion status of its package or superpackage if that has been set. Otherwise returns the default assertion status. Returns 1 for enabled and 0 for disabled.
cname | the name of class. |
boolean java.lang.ClassLoader.getPackageAssertionStatus | ( | String | pname | ) | [package] |
Answers the assertion status of the named package Returns the assertion status of the named package or superpackage if that has been set.
Otherwise returns the default assertion status. Returns 1 for enabled and 0 for disabled.
pname | the name of package. |
boolean java.lang.ClassLoader.getDefaultAssertionStatus | ( | ) | [package] |
Answers the default assertion status.
ClassLoader java.lang.ClassLoader.systemClassLoader [static, package] |
Genereated on Tue Dec 9 14:09:47 2008 by Doxygen.
(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.