public class ClassFileLoader
extends java.net.URLClassLoader
Red (tfeng) |
Red (tfeng) |
Constructor and Description |
---|
ClassFileLoader()
Construct a class loader with no special class path.
|
ClassFileLoader(java.lang.String[] classPaths)
Construct a class loader with a set of class paths specified
as a string array.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Class |
loadClass(java.io.File classFile)
Load a class defined in a file, and return the
Class object of
the class. |
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public ClassFileLoader() throws java.net.MalformedURLException
java.net.MalformedURLException
- If a string is not a proper URL.public ClassFileLoader(java.lang.String[] classPaths) throws java.net.MalformedURLException
classPaths
- The array of class paths to be searched in order.java.net.MalformedURLException
- If a string is not a proper URL.public java.lang.Class loadClass(java.io.File classFile) throws java.io.FileNotFoundException, java.io.IOException, java.lang.LinkageError, java.lang.ClassNotFoundException
Class
object of
the class.classFile
- The file that defines the class.java.io.FileNotFoundException
- If the file cannot be found.java.io.IOException
- If error occurs when trying to read the file.java.lang.LinkageError
- If URLClassLoader.defineClass(java.lang.String, sun.misc.Resource)
issues a LinkageError
and fails to define the class.java.lang.ClassNotFoundException
- If some classes referenced by the
class in the file cannot be found.