Class ClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- Direct Known Subclasses:
URLClassLoader
public class ClassLoader extends Object
This stripped down ClassLoader class is simply here to give us cross-platform support for code that might need a valid classloader.xapi-gwt-reflect does call into the one and only system classloader, to define mappings of java-names to runtime classes, in order to enable Class.forName() and ClassLoader.loadClass();
- Author:
- "James X. Nelson (james@wetheinter.net)"
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedClassLoader()Creates a new class loader using the ClassLoader returned by the methodgetSystemClassLoader()as the parent class loader.protectedClassLoader(ClassLoader parent)Creates a new class loader using the specified parent class loader for delegation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Class<?>findClass(String name)Finds the class with the specified binary name.protected Class<?>findSystemClass(String name)Finds a class with the specified binary name, loading it if necessary.ClassLoadergetParent()Returns the parent class loader for delegation.URLgetResource(String name)InputStreamgetResourceAsStream(String name)Unsupported.static ClassLoadergetSystemClassLoader()get system class loader.static InputStreamgetSystemResourceAsStream(String name)Unsupported.Class<?>loadClass(String name)Loads the class with the specified binary name.protected Class<?>loadClass(String name, boolean resolve)Loads the class with the specified binary name.protected voidsetSigners(Class<?> pclass, Object[] signers)No-op for compatibility.
-
-
-
Constructor Detail
-
ClassLoader
protected ClassLoader(ClassLoader parent)
Creates a new class loader using the specified parent class loader for delegation.- Parameters:
parent- The parent class loader
-
ClassLoader
protected ClassLoader()
Creates a new class loader using the ClassLoader returned by the methodgetSystemClassLoader()as the parent class loader.
-
-
Method Detail
-
loadClass
public Class<?> loadClass(String name) throws ClassNotFoundException
Loads the class with the specified binary name. This method searches for classes in the same manner as theloadClass(String, boolean)method. It is invoked by the Java virtual machine to resolve class references. Invoking this method is equivalent to invokingloadClass(name, false).- Parameters:
name- The binary name of the class- Returns:
- The resulting Class object
- Throws:
ClassNotFoundException- If the class was not found
-
loadClass
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
Loads the class with the specified binary name. The default implementation of this method searches for classes in the following order:-
Invoke
#findLoadedClass(String)to check if the class has already been loaded. -
Invoke the
loadClassmethod on the parent class loader. If the parent is null the class loader built-in to the virtual machine is used, instead. -
Invoke the
findClass(String)method to find the class.
If the class was found using the above steps, and the resolve flag is true, this method will then invoke the
#resolveClass(Class)method on the resulting Class object.Subclasses of ClassLoader are encouraged to override
findClass(String), rather than this method.- Parameters:
name- The binary name of the classresolve- If true then resolve the class- Returns:
- The resulting Class object
- Throws:
ClassNotFoundException- If the class could not be found
-
-
findClass
protected Class<?> findClass(String name) throws ClassNotFoundException
Finds the class with the specified binary name. This method should be overridden by class loader implementations that follow the delegation model for loading classes, and will be invoked by theloadClassmethod after checking the parent class loader for the requested class. The default implementation throws a ClassNotFoundException.- Parameters:
name- The binary name of the class- Returns:
- The resulting Class object
- Throws:
ClassNotFoundException- If the class could not be found- Since:
- 1.2
-
findSystemClass
protected final Class<?> findSystemClass(String name) throws ClassNotFoundException
Finds a class with the specified binary name, loading it if necessary.This method loads the class through the system class loader (see
getSystemClassLoader()). The Class object returned might have more than one ClassLoader associated with it. Subclasses of ClassLoader need not usually invoke this method, because most class loaders need to override justfindClass(String).- Parameters:
name- The binary name of the class- Returns:
- The Class object for the specified name
- Throws:
ClassNotFoundException- If the class could not be found- See Also:
ClassLoader(ClassLoader),getParent()
-
setSigners
protected final void setSigners(Class<?> pclass, Object[] signers)
No-op for compatibility.
-
getResourceAsStream
public InputStream getResourceAsStream(String name)
Unsupported.
-
getSystemResourceAsStream
public static InputStream getSystemResourceAsStream(String name)
Unsupported.
-
getParent
public final ClassLoader getParent()
Returns the parent class loader for delegation. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class loader's parent is the bootstrap class loader.
-
getSystemClassLoader
public static ClassLoader getSystemClassLoader()
get system class loader.- Returns:
- ClassLoader
-
-