|
![]() |
|||||||||
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
ClassLoader provides a new name space for classes that are loaded into the system from an external source.
Constructor Summary | |
---|---|
protected |
ClassLoader()
Constructor to create a class loader with system class loader as parent. |
protected |
ClassLoader(ClassLoader parent)
Constructor to create a class loader with the given parent. |
Method Summary | |
---|---|
void |
clearAssertionStatus()
clearAssertionStatus removes all the assertion status settings for classes, packages and for this class loader. |
protected Class<?> |
defineClass(byte[] b,
int off,
int len)
Deprecated. use defineClass(String,byte[],int,int) instead. |
protected Class<?> |
defineClass(String name,
byte[] b,
int off,
int len)
Define a class from the give class file data. |
protected Class<?> |
defineClass(String name,
byte[] b,
int off,
int len,
ProtectionDomain domain)
Define a class from the give class file data. |
protected Class<?> |
defineClass(String name,
ByteBuffer b,
ProtectionDomain protectionDomain)
defineClass |
protected Package |
definePackage(String name,
String specTitle,
String specVersion,
String specVendor,
String implTitle,
String implVersion,
String implVendor,
URL sealBase)
Defines a Package object for classes that are loaded through this ClassLoader. |
protected Class<?> |
findClass(String name)
Find a class with the given name. |
protected String |
findLibrary(String libname)
findLibrary returns the path to load a shared library with the given name. |
protected Class<?> |
findLoadedClass(String name)
findLoadedClass searches for a class with given name that was loaded by this class loader. |
protected URL |
findResource(String name)
findResource find a resource with a given name. |
protected Enumeration<URL> |
findResources(String name)
findResources returns an enumeration of URLs for the resource with the given name. |
protected Class<?> |
findSystemClass(String name)
Load class from the system class loader. |
protected Package |
getPackage(String name)
Get the Package object for the named package if it is defined in this ClassLoader or in one of its ancestors. |
protected Package[] |
getPackages()
getPackages returns an array of all packages defined by this class loader and all of its ancestors. |
ClassLoader |
getParent()
getParent return the parent class loader of this class loader instance. |
URL |
getResource(String name)
getResource returns an URL for a resource with the given name. |
InputStream |
getResourceAsStream(String name)
getResourceAsStream finds a resource with the given name and opens an InputStream to read the resource data. |
Enumeration<URL> |
getResources(String name)
getResources returns an enumeration of URLs for the resource with the given name. |
static ClassLoader |
getSystemClassLoader()
getSystemClassLoader returns the system class loader. |
static URL |
getSystemResource(String name)
getSystemResource determines the location of a resource in the system class path. |
static InputStream |
getSystemResourceAsStream(String name)
getSystemResourceAsStream finds a resource of the system class loader with the given name and opens an InputStream to read the resource data. |
static Enumeration<URL> |
getSystemResources(String name)
getSystemResources determines the locations of all resources with a given name in the system class path. |
Class<?> |
loadClass(String name)
Load a class from this class loader without resolving it. |
protected Class<?> |
loadClass(String name,
boolean resolve)
Load a class from this class loader, optionally resolving it. |
protected void |
resolveClass(Class<?> cl)
Resolve a class. |
void |
setClassAssertionStatus(String name,
boolean enabled)
setClassAssertionStatus sets the assertion status for a class with a given name. |
void |
setDefaultAssertionStatus(boolean enabled)
setDefaultAssertionStatus enables or disables assertion checking for classes loaded via this class loader. |
void |
setPackageAssertionStatus(String name,
boolean enabled)
setPackageAssertionStatus sets the assertion status for all classes in a package and all sub-packages of this package. |
protected void |
setSigners(Class<?> c,
Object[] signers)
setSigners sets the signers for a class to the given object array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ClassLoader(ClassLoader parent)
parent
- the parent class loader.
if
- SecurityManager sm is installed and
sm.checkCreateClassLoader() throws this exception.protected ClassLoader()
if
- SecurityManager sm is installed and
sm.checkCreateClassLoader() throws this exception.Method Detail |
---|
public Class<?> loadClass(String name) throws ClassNotFoundException
name
- the class name, e.g., "java.lang.Object"
ClassNotFoundException
- if loading of the class failed.protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
name
- the class name, e.g., "java.lang.Object"resolve
- true if the class should be resolved.
ClassNotFoundException
- if loading of the class failed.protected Class<?> findClass(String name) throws ClassNotFoundException
name
- the class name, e.g. "jav.lang.Object"
ClassNotFoundException
- if the class was not found.protected final Class<?> defineClass(byte[] b, int off, int len) throws ClassFormatError
b
- the bytecode array for the class file dataoff
- the starting index of the class file data in blen
- the length of the class file data in b
LinkageError
- if linking of the class failed.
ClassFormatError
- if the class file data did not specify a
proper class file
OutOfMemoryError
- if loading failed due to low memory
StackOverflowError
- if loading failed due to stack overflow
ClassNotFoundException
- if loading failed because super
class or super interface was not found.
IndexOutOfBoundsException
- if off<0, len<0 or
off+len>b.length.
SecurityException
- if loaded class is in package "java..."
or class loaded into package with signed classes.protected final Class<?> defineClass(String name, byte[] b, int off, int len) throws ClassFormatError
name
- the expected name of the classb
- the bytecode array for the class file dataoff
- the starting index of the class file data in blen
- the length of the class file data in b
LinkageError
- if linking of the class failed.
ClassFormatError
- if the class file data did not specify a
proper class file
OutOfMemoryError
- if loading failed due to low memory
StackOverflowError
- if loading failed due to stack overflow
ClassNotFoundException
- if loading failed because super
class or super interface was not found.
IndexOutOfBoundsException
- if off<0, len<0 or
off+len>b.length.
SecurityException
- if loaded class is in package "java..."
or class loaded into package with signed classes.protected final Class<?> defineClass(String name, byte[] b, int off, int len, ProtectionDomain domain) throws ClassFormatError
name
- the expected name of the classb
- the bytecode array for the class file dataoff
- the starting index of the class file data in blen
- the length of the class file data in bdomain
- the protection domain of the class
LinkageError
- if linking of the class failed.
ClassFormatError
- if the class file data did not specify a
proper class file or the class that was specified has a different
name than the name argument that was specified
OutOfMemoryError
- if loading failed due to low memory
StackOverflowError
- if loading failed due to stack overflow
ClassNotFoundException
- if loading failed because super
class or super interface was not found.
IndexOutOfBoundsException
- if off<0, len<0 or
off+len>b.length.
SecurityException
- if loaded class is in package "java..."
or class loaded into package with signed classes.protected final void resolveClass(Class<?> cl)
cl
- The class to be linked.
NullPointerException
- if cl==nullprotected final Class<?> findSystemClass(String name) throws ClassNotFoundException
name
- of the class, using '.' as package separator.
ClassNotFoundException
- if loading of the class failed.
LinkageError
- if linking of the class failed.public final ClassLoader getParent()
SecurityException
- if a SecurityManager sm is installed
and the caller of this method was loaded by a class loader that
is not an ancestor of this and sm.checkPermission(new
RuntimePermission("getClassLoader")) throws this exception.protected final void setSigners(Class<?> c, Object[] signers)
c
- the class whose signers should be set.signers
- an array of the signers.protected final Class<?> findLoadedClass(String name)
name
- the name of the class, e.g., "java.lang.Object"
public URL getResource(String name)
name
- the resource.
public Enumeration<URL> getResources(String name) throws IOException
name
- the name of the resource
IOException
- if an IOException occurs while collecting the
resources.protected Enumeration<URL> findResources(String name) throws IOException
name
- the name of the resource
IOException
- if an IOException occurs while collecting the
resources.protected URL findResource(String name)
name
- the name of the resource
public static URL getSystemResource(String name)
name
- the name of the resource
public static Enumeration<URL> getSystemResources(String name) throws IOException
name
- the name of the resource.
IOException
- if an IOException occurs while collecting the
resources.public InputStream getResourceAsStream(String name)
name
- name of the resource
public static InputStream getSystemResourceAsStream(String name)
name
- name of the resource
public static ClassLoader getSystemClassLoader()
SecurityException
- if a SecurityManager sm is installed
and the caller of this method was loaded by a class loader that
is not an ancestor of this and sm.checkPermission(new
RuntimePermission("getClassLoader")) throws this exception.
IllegalStateException
- if this is called from the
constructor of the system class loader instance.
Error
- if property "java.system.class.loader" is defined
and the corresponding class loader could not be loaded or
instantiated.protected Package definePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase) throws IllegalArgumentException
name
- of the package to definespecTitle
- its specification titlespecVersion
- its specification versionspecVendor
- its specification vendorimplTitle
- its implementation titleimplVersion
- its implementation versionimplVendor
- its implementation vendor.sealBase
- null for a non-sealed package, else URL to code
base for seal.
IllegalArgumentException
- if the package is already definedprotected Package getPackage(String name)
name
- of the Package
protected Package[] getPackages()
protected String findLibrary(String libname)
For JamaicaVM, this always returns null.
libname
- the library name.
public void setDefaultAssertionStatus(boolean enabled)
enabled
- true to enable assertion checking, false to
disable checking.public void setPackageAssertionStatus(String name, boolean enabled)
name
- the name of the packageenabled
- true to enable assertion checking, false to
disable checking.public void setClassAssertionStatus(String name, boolean enabled)
name
- the class nameenabled
- true to enable assertion checking, false to
disable checking.public void clearAssertionStatus()
protected final Class<?> defineClass(String name, ByteBuffer b, ProtectionDomain protectionDomain) throws ClassFormatError
name
- b
- protectionDomain
-
ClassFormatError
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |