corda/classpath/avian/SystemClassLoader.java
Joel Dice d819a75f36 more work towards OpenJDK classpath support
The biggest change in this commit is to split the system classloader
into two: one for boot classes (e.g. java.lang.*) and another for
application classes.  This is necessary to make OpenJDK's security
checks happy.

The rest of the changes include bugfixes and additional JVM method
implementations in classpath-openjdk.cpp.
2010-09-14 10:49:41 -06:00

44 lines
1.2 KiB
Java

/* Copyright (c) 2008-2009, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
package avian;
import java.net.URL;
import java.net.MalformedURLException;
public class SystemClassLoader extends ClassLoader {
private native VMClass findVMClass(String name)
throws ClassNotFoundException;
protected Class findClass(String name) throws ClassNotFoundException {
return getClass(findVMClass(name));
}
public static native Class getClass(VMClass vmClass);
private native VMClass findLoadedVMClass(String name);
protected Class reallyFindLoadedClass(String name){
VMClass c = findLoadedVMClass(name);
return c == null ? null : getClass(c);
}
private native boolean resourceExists(String name);
protected URL findResource(String name) {
if (resourceExists(name)) {
try {
return new URL("resource:" + name);
} catch (MalformedURLException ignored) { }
}
return null;
}
}