2007-07-21 17:50:26 +00:00
|
|
|
package java.lang;
|
|
|
|
|
2007-07-30 23:19:05 +00:00
|
|
|
public abstract class ClassLoader {
|
|
|
|
private final ClassLoader parent;
|
2007-07-27 02:39:53 +00:00
|
|
|
|
2007-07-30 23:19:05 +00:00
|
|
|
protected ClassLoader(ClassLoader parent) {
|
|
|
|
if (parent == null) {
|
|
|
|
this.parent = getSystemClassLoader();
|
|
|
|
} else {
|
|
|
|
this.parent = parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected ClassLoader() {
|
|
|
|
this(getSystemClassLoader());
|
|
|
|
}
|
2007-07-27 02:39:53 +00:00
|
|
|
|
|
|
|
public static ClassLoader getSystemClassLoader() {
|
2007-07-30 23:19:05 +00:00
|
|
|
return ClassLoader.class.getClassLoader();
|
|
|
|
}
|
|
|
|
|
|
|
|
private static native Class defineClass(byte[] b, int offset, int length);
|
|
|
|
|
|
|
|
protected Class defineClass(String name, byte[] b, int offset, int length) {
|
|
|
|
if (b == null) {
|
|
|
|
throw new NullPointerException();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (offset < 0 || offset > length || offset + length > b.length) {
|
|
|
|
throw new IndexOutOfBoundsException();
|
|
|
|
}
|
|
|
|
|
|
|
|
return defineClass(b, offset, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Class findClass(String name) throws ClassNotFoundException {
|
|
|
|
throw new ClassNotFoundException();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Class findLoadedClass(String name) {
|
|
|
|
return null;
|
2007-07-27 23:56:19 +00:00
|
|
|
}
|
|
|
|
|
2007-07-28 16:55:24 +00:00
|
|
|
public Class loadClass(String name) throws ClassNotFoundException {
|
2007-07-30 23:19:05 +00:00
|
|
|
return loadClass(name, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Class loadClass(String name, boolean resolve)
|
|
|
|
throws ClassNotFoundException
|
|
|
|
{
|
|
|
|
Class c = findLoadedClass(name);
|
|
|
|
if (c == null) {
|
|
|
|
if (parent != null) {
|
|
|
|
try {
|
|
|
|
c = parent.loadClass(name);
|
|
|
|
} catch (ClassNotFoundException ok) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c == null) {
|
|
|
|
c = findClass(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resolve) {
|
|
|
|
resolveClass(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void resolveClass(Class c) {
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
private ClassLoader getParent() {
|
|
|
|
return parent;
|
2007-07-27 23:56:19 +00:00
|
|
|
}
|
2007-07-21 17:50:26 +00:00
|
|
|
}
|