|
||||||||||
| 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.ShadowingClassLoader
public class ShadowingClassLoader
A class loader that hides a set of classes and related resources. This allows classes with the same name (but perhaps a different implementation) to be cleanly loaded by a child loader.
| Constructor Summary | |
|---|---|
ShadowingClassLoader(ClassLoader parent,
boolean blackList,
Iterable<? extends String> prefixes,
boolean filterBootClasses)
|
|
| Method Summary | |
|---|---|
static ShadowingClassLoader |
blackList(ClassLoader parent,
String... excludePrefixes)
Create a ShadowingClassLoader that will hide non-bootstrap classes matching the given prefixes. |
URL |
getResource(String name)
|
protected Class<?> |
loadClass(String name,
boolean resolve)
If the given class is shadowed, a ClassNotFoundException will
occur; otherwise, the method delegates to the parent class loader. |
static ShadowingClassLoader |
whiteList(ClassLoader parent,
String... includePrefixes)
Create a ShadowingClassLoader that will hide all non-bootstrap classes except those matching the given prefixes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ShadowingClassLoader(ClassLoader parent,
boolean blackList,
Iterable<? extends String> prefixes,
boolean filterBootClasses)
parent - The parent loaderblackList - If true, classes matching prefixes are prevented from loading; otherwise,
all classes except those matching prefixes are prevented from loading.prefixes - A set of class name prefixes to which class names will be compared. Each prefix must
be a package or class name (partial names, like "java.lang.Stri", will not
match the full class name).filterBootClasses - Whether classes and resources available to the bootstrap class loader should
be hidden. If true, care must be taken to ensure that essential
classes (like java.lang.Object) are available when needed.| Method Detail |
|---|
public static ShadowingClassLoader blackList(ClassLoader parent,
String... excludePrefixes)
parent - The parent loaderexcludePrefixes - A set of class name prefixes to match. Each prefix must be a package or class
name (partial names, like "java.lang.Stri", will not match the full class
name).
public static ShadowingClassLoader whiteList(ClassLoader parent,
String... includePrefixes)
parent - The parent loaderincludePrefixes - A set of class name prefixes to match. Each prefix must be a package or class
name (partial names, like "java.lang.Stri", will not match the full class
name).
protected Class<?> loadClass(String name,
boolean resolve)
throws ClassNotFoundException
ClassNotFoundException will
occur; otherwise, the method delegates to the parent class loader.
loadClass in class ClassLoaderClassNotFoundExceptionpublic URL getResource(String name)
getResource in class ClassLoader
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||