Class ClassLoader
- Direct Known Subclasses:
URLClassLoader
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
ConstructorsModifierConstructorDescriptionprotectedCreates a new class loader using theClassLoaderreturned by the methodas the parent class loader.getSystemClassLoader()protectedClassLoader(ClassLoader parent) Creates a new class loader using the specified parent class loader for delegation. -
Method Summary
Modifier and TypeMethodDescriptionprotected Class<?>Finds the class with the specified binary name.protected final Class<?>findSystemClass(String name) Finds a class with the specified binary name, loading it if necessary.final ClassLoaderReturns the parent class loader for delegation.getResource(String name) getResourceAsStream(String name) Unsupported.static ClassLoaderget system class loader.static InputStreamUnsupported.Class<?>Loads the class with the specified binary name.protected Class<?>Loads the class with the specified binary name.protected final voidsetSigners(Class<?> pclass, Object[] signers) No-op for compatibility.
-
Constructor Details
-
ClassLoader
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 theClassLoaderreturned by the methodas the parent class loader.getSystemClassLoader()
-
-
Method Details
-
loadClass
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 invoking.loadClass(name, false)- Parameters:
name- The binary name of the class- Returns:
- The resulting
Classobject - Throws:
ClassNotFoundException- If the class was not found
-
loadClass
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
method on the parent class loader. If the parent isloadClassnullthe 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
resolveflag is true, this method will then invoke theresolveClass(Class)method on the resultingClassobject.Subclasses of
ClassLoaderare encouraged to overridefindClass(String), rather than this method.- Parameters:
name- The binary name of the classresolve- Iftruethen resolve the class- Returns:
- The resulting
Classobject - Throws:
ClassNotFoundException- If the class could not be found
-
-
findClass
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 themethod after checking the parent class loader for the requested class. The default implementation throws aloadClassClassNotFoundException.- Parameters:
name- The binary name of the class- Returns:
- The resulting
Classobject - Throws:
ClassNotFoundException- If the class could not be found- Since:
- 1.2
-
findSystemClass
Finds a class with the specified binary name, loading it if necessary.This method loads the class through the system class loader (see
getSystemClassLoader()). TheClassobject returned might have more than oneClassLoaderassociated with it. Subclasses ofClassLoaderneed not usually invoke this method, because most class loaders need to override justfindClass(String).- Parameters:
name- The binary name of the class- Returns:
- The
Classobject for the specifiedname - Throws:
ClassNotFoundException- If the class could not be found- See Also:
-
setSigners
No-op for compatibility. -
getResource
-
getResourceAsStream
Unsupported. -
getSystemResourceAsStream
Unsupported. -
getParent
Returns the parent class loader for delegation. Some implementations may usenullto represent the bootstrap class loader. This method will returnnullin such implementations if this class loader's parent is the bootstrap class loader. -
getSystemClassLoader
get system class loader.- Returns:
- ClassLoader
-