|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.ClassLoader
public abstract class ClassLoader
A ClassLoader is used for loading classes.
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.
Class| Constructor Summary | |
|---|---|
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. |
| Method Summary | |
|---|---|
(package private) static ClassLoader |
callerClassLoader()
This method must be included, as it is used by System.load(), System.loadLibrary(). |
void |
clearAssertionStatus()
Clears the default, package and class assertion status of a classloader |
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 b,
ProtectionDomain protectionDomain)
Defines a new class for the name, bytecodes in the byte buffer and the 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)
Returns 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)
Returns 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)
Returns 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. |
(package private) boolean |
getClassAssertionStatus(String cname)
Returns the assertion status of the named class Returns the assertion status of the class or nested class if it has been set. |
(package private) boolean |
getDefaultAssertionStatus()
Returns the default assertion status |
(package private) static Package |
getPackage(ClassLoader loader,
String name)
Attempt to locate the requested package using the given class loader. |
protected Package |
getPackage(String name)
Attempt to locate the requested package. |
(package private) boolean |
getPackageAssertionStatus(String pname)
Returns the assertion status of the named package Returns the assertion status of the named package or superpackage if that has been set. |
protected Package[] |
getPackages()
Return all the packages known to this class loader. |
ClassLoader |
getParent()
Returns the specified ClassLoader's parent. |
URL |
getResource(String resName)
Returns 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)
Returns a stream on a resource found by looking up resName using the class loader's resource lookup algorithm. |
Enumeration<URL> |
getResources(String resName)
Returns an Enumeration of URL which can be used to access the resources described by resName, using the class loader's resource lookup algorithm. |
(package private) Object[] |
getSigners(Class<?> c)
Gets the signers of a class. |
(package private) static ClassLoader |
getStackClassLoader(int depth)
This must be provided by the VM vendor. |
static ClassLoader |
getSystemClassLoader()
Returns the system class loader. |
static URL |
getSystemResource(String resName)
Returns 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)
Returns 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)
Returns an Enumeration of URLs containing all resources which can be found by looking up resName using the system class loader's resource lookup algorithm. |
(package private) boolean |
isAncestorOf(ClassLoader child)
Returns true if the receiver is ancestor of another class loader. |
(package private) boolean |
isSystemClassLoader()
This method must be provided by the VM vendor, as it is used by other provided class implementations in this package. |
Class<?> |
loadClass(String className)
Invoked by the Virtual Machine when resolving class references. |
protected Class<?> |
loadClass(String className,
boolean resolve)
Loads the class with the specified name, optionally linking the class after load. |
(package private) 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(). |
(package private) 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(). |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected ClassLoader()
SecurityException - if a security manager exists and it does not
allow the creation of new ClassLoaders.protected ClassLoader(ClassLoader parentLoader)
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.| Method Detail |
|---|
public static ClassLoader getSystemClassLoader()
SecurityException - if a security manager exists and it does not
allow access to the system class loader.public static URL getSystemResource(String resName)
resName - 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.
IOExceptionpublic static InputStream getSystemResourceAsStream(String resName)
resName - The name of the resource to find.
Class.getResourceAsStream(java.lang.String)
@Deprecated
protected final Class<?> defineClass(byte[] classRep,
int offset,
int length)
throws ClassFormatError
defineClass(String, byte[], int, int)
classRep - A memory image of a class file.offset - The offset into the classRep.length - The length of the class file.
ClassFormatError
protected final Class<?> defineClass(String className,
byte[] classRep,
int offset,
int length)
throws ClassFormatError
className - The name of the new classclassRep - A memory image of a class fileoffset - The offset into the classReplength - The length of the class file
ClassFormatError
protected final Class<?> defineClass(String className,
byte[] classRep,
int offset,
int length,
ProtectionDomain protectionDomain)
throws ClassFormatError
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.
ClassFormatError
protected final Class<?> defineClass(String name,
ByteBuffer b,
ProtectionDomain protectionDomain)
throws ClassFormatError
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.
protected Class<?> findClass(String className)
throws ClassNotFoundException
className - The name of the class to search for.
ClassNotFoundException - if the class cannot be found.protected final Class<?> findLoadedClass(String className)
className - The name of the class to search for.
protected final Class<?> findSystemClass(String className)
throws ClassNotFoundException
className - The name of the class to search for.
ClassNotFoundException - if the class cannot 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.
IOExceptionpublic InputStream getResourceAsStream(String resName)
resName - String the name of the resource to find.
Class.getResourceAsStream(java.lang.String)
public Class<?> loadClass(String className)
throws ClassNotFoundException
className - The name of the class to search for.
ClassNotFoundException - if the class could not be found.
protected Class<?> loadClass(String className,
boolean resolve)
throws ClassNotFoundException
className - The name of the class to search for.resolve - Indicates if class should be resolved after loading.
Note: On the android reference implementation this parameter
does not have any effect.
ClassNotFoundException - if the class could not be found.protected final void resolveClass(Class<?> clazz)
clazz - The Class to link.
NullPointerException - if clazz is null.Class.getResource(java.lang.String)final boolean isSystemClassLoader()
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(). Returns 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 loaderClass.getClassLoaderImpl()final boolean isAncestorOf(ClassLoader child)
Returns true if the receiver is ancestor of another class loader. It also returns true if the two class loader are equal.
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. The method is also required in other places where class loaders are accesses.
child - A child candidate
true if the receiver is ancestor of, or equal to,
the parameterprotected URL findResource(String resName)
resName - The name of the resource to find.
protected Enumeration<URL> findResources(String resName)
throws IOException
resName - The name of the resource to find.
IOException - when an error occursprotected String findLibrary(String libName)
libName - The name of the library to find.
protected Package getPackage(String name)
name - The name of the package to find
static Package getPackage(ClassLoader loader,
String name)
loader - The class loader to usename - The name of the package to find
protected 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 - If sealBase is null, the package is left unsealed.
Otherwise, the the package is sealed using this URL.
IllegalArgumentException - if the Package already existsfinal Object[] getSigners(Class<?> c)
c - The Class object
protected final void setSigners(Class<?> c,
Object[] signers)
c - The Class objectsigners - The signers for the classstatic final ClassLoader getStackClassLoader(int depth)
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 callerClassLoader()
static void loadLibraryWithClassLoader(String libName,
ClassLoader loader)
libName - the name of the library to loadloader - 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 loadLibraryWithPath(String libName,
ClassLoader loader,
String libraryPath)
libName - the name of the library to loadloader - the classloader in which to load the librarylibraryPath - the library path to search, or null
UnsatisfiedLinkError - if the library could not be loaded
public void setClassAssertionStatus(String cname,
boolean enable)
cname - Class nameenable - Enable or disable assertion
public void setPackageAssertionStatus(String pname,
boolean enable)
pname - Package nameenable - Enable or disable assertionpublic void setDefaultAssertionStatus(boolean enable)
enable - Enable or disable assertionpublic void clearAssertionStatus()
boolean getClassAssertionStatus(String cname)
cname - the name of class.
boolean getPackageAssertionStatus(String pname)
pname - the name of package.
boolean getDefaultAssertionStatus()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||