Hi,

ResourceBundle doesn't work correctly anymore when getBundle() is called
from a user defined class loader Class. This is because
VMSecurityManager.getClassContext() doesn't obey its interface:
"Hint: you may need to pop off one or more frames: don't include
SecurityManager or VMSecurityManager.getClassContext in your result. " 

This patch fixes that:

2004-12-05  Mark Wielaard  <[EMAIL PROTECTED]>

        * libraries/javalib/java/lang/ClassLoader.java
        (setSigners): Don't throw Exception.
        * libraries/javalib/java/lang/VMSecurityManager.java
        (getClassContext): Cleanup returned stack.

This isn't the most efficient way to handle this for ResourceBundle. We
should probably introduce a VMResourceBundle that gives kaffe the option
to do it the efficient way as Helmer once introduced. But this patch
also fixes other potential bugs in the use of the SecurityManager
getClassContext() method.

It also tries to sneak in the patch to make ClassLoader.setSigners() not
throw exceptions for anything that uses signed jar files (Casey his
patch is way better, but I want to get at least something in to make
kaffe CVS usable again.)

Cheers,

Mark
Index: libraries/javalib/java/lang/ClassLoader.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/ClassLoader.java,v
retrieving revision 1.33
diff -u -r1.33 ClassLoader.java
--- libraries/javalib/java/lang/ClassLoader.java	14 Nov 2004 17:07:22 -0000	1.33
+++ libraries/javalib/java/lang/ClassLoader.java	5 Dec 2004 11:41:42 -0000
@@ -206,8 +206,6 @@
 }
 
 protected final void setSigners(Class cl, Object signers[]) {
-	throw new kaffe.util.NotImplemented(getClass().getName()
-		+ ".setSigners()");
 }
 
 protected final Class findLoadedClass(String name) {
Index: libraries/javalib/java/lang/VMSecurityManager.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/VMSecurityManager.java,v
retrieving revision 1.2
diff -u -r1.2 VMSecurityManager.java
--- libraries/javalib/java/lang/VMSecurityManager.java	7 Apr 2004 21:11:06 -0000	1.2
+++ libraries/javalib/java/lang/VMSecurityManager.java	5 Dec 2004 11:41:42 -0000
@@ -58,7 +58,19 @@
    * @return an array of the declaring classes of each stack frame
    */
   static Class[] getClassContext() {
-    return (ThreadStack.getClassStack());
+    Class[] rawStack = ThreadStack.getClassStack();
+    int i = 0;
+    while (i < rawStack.length
+	   && (rawStack[i] == ThreadStack.class
+	       || rawStack[i] == VMSecurityManager.class
+	       || rawStack[i] == SecurityManager.class))
+      i++;
+
+    Class[] stack = new Class[rawStack.length - i];
+    for (int j = 0; j < stack.length; j++, i++)
+      stack[j] = rawStack[i];
+
+    return stack;
   }
 
   /**

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to