|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.ClassLoader
edu.rice.cs.plt.reflect.AbstractClassLoader
edu.rice.cs.plt.reflect.PathClassLoader
public class PathClassLoader
A class loader that mimics the standard application system loader by loading classes from
a file path of directories and jar files. This class also supports a dynamic
class path: an Iterable provided as input to the constructor is held, not copied,
and subsequent changes to that iterable are reflected in the path that is searched. Of
course, once a class is loaded, subsequent changes to the path will not change the class
bound to that name. The dynamic nature of the search path makes possible unusual errors --
a class may be valid in the path in which it is initially loaded, but when the JVM
later transitively resolves the referenced classes, they may no longer exist, or may be
shadowed. This is not a unique problem, however -- the standard system class loader is
based on an underlying file system that may also change in arbitrary ways at any time.
| Constructor Summary | |
|---|---|
PathClassLoader(ClassLoader parent,
File... path)
Create a path class loader with the given parent and path |
|
PathClassLoader(ClassLoader parent,
Iterable<? extends File> path)
Create a path class loader with the given parent and path |
|
PathClassLoader(File... path)
Create a path class loader with the default parent ( ClassLoader.getSystemClassLoader())
and the specified path. |
|
PathClassLoader(Iterable<? extends File> path)
Create a path class loader with the default parent ( ClassLoader.getSystemClassLoader())
and the specified path. |
|
| Method Summary | |
|---|---|
protected Class<?> |
findClass(String name)
|
protected URL |
findResource(String name)
|
protected Enumeration<URL> |
findResources(String name)
|
static URL |
getResourceInPath(String name,
File... path)
Locate a resource in the given path. |
static URL |
getResourceInPath(String name,
Iterable<File> path)
Locate a resource in the given path. |
static InputStream |
getResourceInPathAsStream(String name,
File... path)
Locate a resource in the given path. |
static InputStream |
getResourceInPathAsStream(String name,
Iterable<File> path)
Locate a resource in the given path. |
| Methods inherited from class edu.rice.cs.plt.reflect.AbstractClassLoader |
|---|
definePackageForClass |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PathClassLoader(File... path)
ClassLoader.getSystemClassLoader())
and the specified path.
public PathClassLoader(Iterable<? extends File> path)
ClassLoader.getSystemClassLoader())
and the specified path.
public PathClassLoader(ClassLoader parent,
File... path)
public PathClassLoader(ClassLoader parent,
Iterable<? extends File> path)
| Method Detail |
|---|
public static URL getResourceInPath(String name,
File... path)
null if the resource is not found.
If multiple queries will be performed on the same path, a PathClassLoader instance
should be created for better performance.
public static URL getResourceInPath(String name,
Iterable<File> path)
null if the resource is not found.
If multiple queries will be performed on the same path, a PathClassLoader instance
should be created for better performance.
public static InputStream getResourceInPathAsStream(String name,
File... path)
null if the resource is not found.
If multiple queries will be performed on the same path, a PathClassLoader instance
should be created for better performance.
public static InputStream getResourceInPathAsStream(String name,
Iterable<File> path)
null if the resource is not found.
If multiple queries will be performed on the same path, a PathClassLoader instance
should be created for better performance.
protected Class<?> findClass(String name)
throws ClassNotFoundException
findClass in class ClassLoaderClassNotFoundExceptionprotected URL findResource(String name)
findResource in class ClassLoader
protected Enumeration<URL> findResources(String name)
throws IOException
findResources in class ClassLoaderIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||