|
|||||
FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This ClassLoader should be used as root of class loaders. Any RootLoader does have it's own classpath. When searching for a class or resource this classpath will be used. Parent Classloaders are ignored first. If a class or resource can't be found in the classpath of the RootLoader, then parent is checked.
Note: this is very against the normal behavior of classloaders. Normal is to first check parent and then look in the resources you gave this classloader. It's possible to add urls to the classpath at runtime throughparentLoader (has classpath: a.jar;c.jar) | | childLoader (has classpath: a.jar;b.jar;c.jar)class C (from c.jar) extends B (from b.jar) childLoader.find("C") --> parentLoader does know C.class, try to load it --> to load C.class it has to load B.class --> parentLoader is unable to find B.class in a.jar or c.jar --> NoClassDefFoundException! if childLoader had tried to load the class by itself, there would be no problem. Changing childLoader to be a RootLoader instance will solve that problem.
Field Summary | |
---|---|
Map |
customClasses
|
Constructor Summary | |
RootLoader(ClassLoader parent)
constructs a new RootLoader without classpath |
|
RootLoader(def urls, ClassLoader parent)
constructs a new RootLoader with a parent loader and an array of URLs as classpath |
|
RootLoader(LoaderConfiguration lc)
constructs a new RootLoader with a object which holds the classpath |
Method Summary | |
---|---|
void |
addURL(URL url)
adds an url to the classpath of this classloader |
static ClassLoader |
chooseParent()
|
Class |
findClass(String name)
|
URL |
getResource(String name)
returns the URL of a resource, or null if it is not found |
Class |
loadClass(String name, boolean resolve)
loads a class using the name of the class |
Class |
oldFindClass(String name)
|
Constructor Detail |
---|
RootLoader(ClassLoader parent)
public RootLoader(def urls, ClassLoader parent)
public RootLoader(LoaderConfiguration lc)
Method Detail |
---|
public void addURL(URL url)
static ClassLoader chooseParent()
Class findClass(String name)
public URL getResource(String name)
Class loadClass(String name, boolean resolve)
Class oldFindClass(String name)