public class RootLoader
extends java.net.URLClassLoader
parentLoader (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.
Constructor and Description |
---|
RootLoader(LoaderConfiguration lc)
constructs a new RootLoader with a
LoaderConfiguration
object which holds the classpath |
RootLoader(java.net.URL[] urls,
java.lang.ClassLoader parent)
constructs a new RootLoader with a parent loader and an
array of URLs as classpath
|
Modifier and Type | Method and Description |
---|---|
void |
addURL(java.net.URL url)
adds an url to the classpath of this classloader
|
protected java.lang.Class |
findClass(java.lang.String name) |
java.net.URL |
getResource(java.lang.String name)
returns the URL of a resource, or null if it is not found
|
protected java.lang.Class |
loadClass(java.lang.String name,
boolean resolve)
loads a class using the name of the class
|
close, definePackage, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public RootLoader(java.net.URL[] urls, java.lang.ClassLoader parent)
public RootLoader(LoaderConfiguration lc)
LoaderConfiguration
object which holds the classpathprotected java.lang.Class loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
java.lang.ClassNotFoundException
public java.net.URL getResource(java.lang.String name)
getResource
in class java.lang.ClassLoader
public void addURL(java.net.URL url)
addURL
in class java.net.URLClassLoader
protected java.lang.Class findClass(java.lang.String name) throws java.lang.ClassNotFoundException
findClass
in class java.net.URLClassLoader
java.lang.ClassNotFoundException