mirror of
https://github.com/corda/corda.git
synced 2025-01-22 12:28:11 +00:00
fix Classpath 0.98 compatibility issues
This commit is contained in:
parent
30db38ebd6
commit
f588a62ae3
@ -29,7 +29,7 @@ public class SystemClassLoader extends ClassLoader {
|
|||||||
|
|
||||||
protected native Class findClass(String name) throws ClassNotFoundException;
|
protected native Class findClass(String name) throws ClassNotFoundException;
|
||||||
|
|
||||||
protected native Class findLoadedClass(String name);
|
protected native Class reallyFindLoadedClass(String name);
|
||||||
|
|
||||||
private native boolean resourceExists(String name);
|
private native boolean resourceExists(String name);
|
||||||
|
|
||||||
|
@ -49,8 +49,10 @@ public abstract class ClassLoader {
|
|||||||
throw new ClassNotFoundException();
|
throw new ClassNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class findLoadedClass(String name) {
|
protected abstract Class reallyFindLoadedClass(String name);
|
||||||
return null;
|
|
||||||
|
protected final Class findLoadedClass(String name) {
|
||||||
|
return reallyFindLoadedClass(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class loadClass(String name) throws ClassNotFoundException {
|
public Class loadClass(String name) throws ClassNotFoundException {
|
||||||
|
@ -10,13 +10,20 @@
|
|||||||
|
|
||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
|
import avian.Cell;
|
||||||
|
|
||||||
public class ThreadGroup implements Thread.UncaughtExceptionHandler {
|
public class ThreadGroup implements Thread.UncaughtExceptionHandler {
|
||||||
private final ThreadGroup parent;
|
final ThreadGroup parent; // package private for GNU Classpath compatibility
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private Cell<ThreadGroup> subgroups;
|
||||||
|
|
||||||
public ThreadGroup(ThreadGroup parent, String name) {
|
public ThreadGroup(ThreadGroup parent, String name) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
|
synchronized (parent) {
|
||||||
|
parent.subgroups = new Cell(this, subgroups);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ThreadGroup(String name) {
|
public ThreadGroup(String name) {
|
||||||
@ -36,4 +43,75 @@ public class ThreadGroup implements Thread.UncaughtExceptionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ThreadGroup getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int activeCount() {
|
||||||
|
int allCount = Thread.activeCount();
|
||||||
|
Thread[] all = new Thread[allCount];
|
||||||
|
allCount = Thread.enumerate(all);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < allCount; ++i) {
|
||||||
|
if (parentOf(all[i].getThreadGroup())) {
|
||||||
|
++ count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int enumerate(Thread[] threads) {
|
||||||
|
return enumerate(threads, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int enumerate(Thread[] threads, boolean recurse) {
|
||||||
|
int allCount = Thread.activeCount();
|
||||||
|
Thread[] all = new Thread[allCount];
|
||||||
|
allCount = Thread.enumerate(all);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < allCount && count < threads.length; ++i) {
|
||||||
|
Thread t = all[i];
|
||||||
|
ThreadGroup g = t.getThreadGroup();
|
||||||
|
if (g == this || (recurse && parentOf(g))) {
|
||||||
|
threads[count++] = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean parentOf(ThreadGroup g) {
|
||||||
|
for (; g != null; g = g.parent) {
|
||||||
|
if (g == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int enumerate(ThreadGroup[] groups, boolean recurse) {
|
||||||
|
return enumerate(groups, recurse, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int enumerate(ThreadGroup[] groups, boolean recurse, int count) {
|
||||||
|
for (Cell<ThreadGroup> c = subgroups; c != null && count < groups.length;
|
||||||
|
c = c.next)
|
||||||
|
{
|
||||||
|
ThreadGroup g = c.value;
|
||||||
|
groups[count++] = g;
|
||||||
|
if (recurse) {
|
||||||
|
count = g.enumerate(groups, true, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,14 @@ public class Proxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isProxyClass(Class c) {
|
||||||
|
return c.getName().startsWith("Proxy-");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InvocationHandler getInvocationHandler(Object proxy) {
|
||||||
|
return ((Proxy) proxy).h;
|
||||||
|
}
|
||||||
|
|
||||||
private static void set4(byte[] array, int offset, int v) {
|
private static void set4(byte[] array, int offset, int v) {
|
||||||
array[offset ] = (byte) ((v >>> 24) & 0xFF);
|
array[offset ] = (byte) ((v >>> 24) & 0xFF);
|
||||||
array[offset + 1] = (byte) ((v >>> 16) & 0xFF);
|
array[offset + 1] = (byte) ((v >>> 16) & 0xFF);
|
||||||
|
@ -214,7 +214,7 @@ Avian_avian_SystemClassLoader_defineClass
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT int64_t JNICALL
|
extern "C" JNIEXPORT int64_t JNICALL
|
||||||
Avian_avian_SystemClassLoader_findLoadedClass
|
Avian_avian_SystemClassLoader_reallyFindLoadedClass
|
||||||
(Thread* t, object, uintptr_t* arguments)
|
(Thread* t, object, uintptr_t* arguments)
|
||||||
{
|
{
|
||||||
object name = reinterpret_cast<object>(arguments[1]);
|
object name = reinterpret_cast<object>(arguments[1]);
|
||||||
|
@ -234,7 +234,7 @@ makeJavaThread(Thread* t, Thread* parent)
|
|||||||
if (parent) {
|
if (parent) {
|
||||||
group = threadGroup(t, parent->javaThread);
|
group = threadGroup(t, parent->javaThread);
|
||||||
} else {
|
} else {
|
||||||
group = makeThreadGroup(t, 0, 0);
|
group = makeThreadGroup(t, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned NewState = 0;
|
const unsigned NewState = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user