Jeroen Frijters wrote:
The infinite loop is simple:
Class.getClassLoader() invokes
VMStackWalker.getCallingClassLoader()
VMStackWalker.getCallingClassLoader() invokes
Class.getClassLoader()
It would be nice if VMStackWalker.getCallingClassLoader() could
invoke VMClass.getClassLoader(), but access permissions prevent that.
Any ideas? One idea is to move VMStackWalker into java.lang.
We can't do that, it needs to be public. I guess that VMStackWalker
should have a native method to get the class loader from a Class.
Sounds good.. how about this?
-Archie
__________________________________________________________________________
Archie Cobbs * CTO, Awarix * http://www.awarix.com
Index: VMStackWalker.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/vm/reference/gnu/classpath/VMStackWalker.java,v
retrieving revision 1.5
diff -u -r1.5 VMStackWalker.java
--- VMStackWalker.java 2 Jul 2005 20:33:08 -0000 1.5
+++ VMStackWalker.java 9 Nov 2005 17:44:29 -0000
@@ -88,9 +88,9 @@
/**
* Get the class loader associated with the Class returned by
- * <code>getCallingClass()</code>, or <code>null</code> if no
- * such class exists or it is the boot loader. This method is an optimization
- * for the expression <code>getClassContext()[1].getClassLoader()</code>
+ * <code>getCallingClass()</code>, or <code>null</code> if no such class
+ * exists or it is the boot loader. This method is an optimization for the
+ * expression <code>VMStackWalker.getClassLoader(getClassContext()[1])</code>
* and should return the same result.
*
* <p>
@@ -102,7 +102,15 @@
Class[] ctx = getClassContext();
if (ctx.length < 3)
return null;
- return ctx[2].getClassLoader();
+ return getClassLoader(ctx[2]);
}
+
+ /**
+ * Retrieve the class's ClassLoader, or <code>null</code> if loaded
+ * by the bootstrap loader. I.e., this should return the same thing
+ * as [EMAIL PROTECTED] java.lang.VMClass#getClassLoader}. This duplicate
version
+ * is here to work around access permissions.
+ */
+ public static native ClassLoader getClassLoader(Class cl);
}
_______________________________________________
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath