Hi,
GNU Classpath CVS needs a new VMClassLoader.firstNonNullClassLoader()
method. Here is a quick and dirty implementation (based on
getCallerFrame()) which works for me.
I have also installed this temporarily on builder.classpath.org to get
mauve results again. We will see how well it does soon :)
Cheers,
Mark
Index: lib/gnu/classpath/VMStackWalker.java
===================================================================
RCS file: /cvsroot/jamvm/jamvm/lib/gnu/classpath/VMStackWalker.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 VMStackWalker.java
--- lib/gnu/classpath/VMStackWalker.java 5 Sep 2005 00:02:35 -0000 1.1.1.1
+++ lib/gnu/classpath/VMStackWalker.java 20 Aug 2006 21:22:50 -0000
@@ -95,5 +95,11 @@
* version of this method.
*/
public static native ClassLoader getCallingClassLoader();
+
+ /**
+ * Walk up the stack and return the first non-null class loader.
+ * If there aren't any non-null class loaders on the stack, return null.
+ */
+ public static native ClassLoader firstNonNullClassLoader();
}
Index: src/natives.c
===================================================================
RCS file: /cvsroot/jamvm/jamvm/src/natives.c,v
retrieving revision 1.17
diff -u -r1.17 natives.c
--- src/natives.c 28 Jun 2006 21:16:08 -0000 1.17
+++ src/natives.c 20 Aug 2006 21:22:50 -0000
@@ -548,6 +548,23 @@
return ostack;
}
+uintptr_t *firstNonNullClassLoader(Class *clazz, MethodBlock *mb, uintptr_t *ostack) {
+ uintptr_t *loader = NULL;
+ Frame *last = getExecEnv()->last_frame->prev;
+ Class *class;
+
+ while (loader == NULL) {
+ if((last->mb == NULL && (last = last->prev)->prev == NULL) ||
+ (last = getCallerFrame(last)) == NULL)
+ return NULL;
+ class = last->mb->class;
+ loader = class ? CLASS_CB(class)->class_loader : NULL;
+ }
+
+ *ostack++ = loader;
+ return ostack;
+}
+
uintptr_t *getClassContext(Class *class, MethodBlock *mb, uintptr_t *ostack) {
Class *class_class = findArrayClass("[Ljava/lang/Class;");
Object *array;
@@ -1149,6 +1166,7 @@
{"getClassContext", getClassContext},
{"getCallingClass", getCallingClass},
{"getCallingClassLoader", getCallingClassLoader},
+ {"firstNonNullClassLoader", firstNonNullClassLoader},
{NULL, NULL}
};