[kaffe] CVS kaffe (hkraemer): small fix for Thread and ResourceBundle
Kaffe CVS
cvs-commits at kaffe.org
Sun Jul 11 07:28:25 PDT 2004
PatchSet 4928
Date: 2004/07/11 13:33:16
Author: hkraemer
Branch: HEAD
Tag: (none)
Log:
small fix for Thread and ResourceBundle
Members:
ChangeLog:1.2493->1.2494
libraries/javalib/java/lang/Package.java:1.5->1.6
libraries/javalib/java/lang/Thread.java:1.45->1.46
libraries/javalib/java/util/ResourceBundle.java:1.19->1.20
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2493 kaffe/ChangeLog:1.2494
--- kaffe/ChangeLog:1.2493 Sun Jul 11 08:54:16 2004
+++ kaffe/ChangeLog Sun Jul 11 13:33:16 2004
@@ -1,3 +1,16 @@
+2004-07-11 Helmer Kraemer <hkraemer at freenet.de>
+
+ * libraries/javalib/java/lang/Package.java (getPackage, getPackages):
+ directly call kaffe.lang.ThreadStack
+ (getCallingClassLoader): removed
+
+ * libraries/javalib/java/lang/Thread.java (setContextClassLoader):
+ call system's SecurityManager instead of AccessController in order to
+ check permission
+
+ * libraries/javalib/java/util/ResourceBundle.java (getBundle):
+ use kaffe.lang.ThreadStack to get caller's classloader
+
2004-07-10 Guilhem Lavaux <guilhem at kaffe.org>
* configure.ac: Check whether we are using GLIBC 2.1 or 2.2.
Index: kaffe/libraries/javalib/java/lang/Package.java
diff -u kaffe/libraries/javalib/java/lang/Package.java:1.5 kaffe/libraries/javalib/java/lang/Package.java:1.6
--- kaffe/libraries/javalib/java/lang/Package.java:1.5 Sat Jun 28 18:06:41 2003
+++ kaffe/libraries/javalib/java/lang/Package.java Sun Jul 11 13:33:25 2004
@@ -53,16 +53,6 @@
this.sealBase = sealBase;
}
- private static ClassLoader getCallingClassLoader() {
- /* We go two steps down the stack,
- * since getCallingClassLoader() is supposed to be called
- * by methods from Package, so we need to skip over them.
- * Otherwise, we would just be getting the same ClassLoader
- * that loaded Package all the time.
- */
- return ThreadStack.getCallersClassLoader(true);
- }
-
public String getImplementationTitle() {
return implTitle;
}
@@ -80,11 +70,11 @@
}
public static Package getPackage(String pname) {
- return getCallingClassLoader().getPackage(pname);
+ return ThreadStack.getCallersClassLoader(true).getPackage(pname);
}
public static Package [] getPackages() {
- return getCallingClassLoader().getPackages();
+ return ThreadStack.getCallersClassLoader(true).getPackages();
}
public String getSpecificationTitle() {
Index: kaffe/libraries/javalib/java/lang/Thread.java
diff -u kaffe/libraries/javalib/java/lang/Thread.java:1.45 kaffe/libraries/javalib/java/lang/Thread.java:1.46
--- kaffe/libraries/javalib/java/lang/Thread.java:1.45 Mon Mar 22 11:24:47 2004
+++ kaffe/libraries/javalib/java/lang/Thread.java Sun Jul 11 13:33:25 2004
@@ -10,7 +10,6 @@
package java.lang;
-import java.security.AccessController;
import java.util.HashMap;
import java.util.Iterator;
@@ -479,7 +478,9 @@
}
public void setContextClassLoader(ClassLoader cl) {
- AccessController.checkPermission(sccl);
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ sm.checkPermission (sccl);
context = cl;
}
Index: kaffe/libraries/javalib/java/util/ResourceBundle.java
diff -u kaffe/libraries/javalib/java/util/ResourceBundle.java:1.19 kaffe/libraries/javalib/java/util/ResourceBundle.java:1.20
--- kaffe/libraries/javalib/java/util/ResourceBundle.java:1.19 Tue Jun 15 18:42:53 2004
+++ kaffe/libraries/javalib/java/util/ResourceBundle.java Sun Jul 11 13:33:26 2004
@@ -105,48 +105,6 @@
private Locale locale;
/**
- * We override SecurityManager in order to access getClassContext().
- */
- private static final class Security extends SecurityManager
- {
- /**
- * Avoid accessor method of private constructor.
- */
- Security()
- {
- }
-
- /**
- * Return the ClassLoader of the class which called into this
- * ResourceBundle, or null if it cannot be determined.
- */
- ClassLoader getCallingClassLoader()
- {
- Class[] stack = getClassContext();
- for (int i = 0; i < stack.length; i++)
- {
- if (stack[i] != Security.class && stack[i] != ResourceBundle.class)
- return stack[i].getClassLoader();
- }
-
- return null;
- }
- }
-
- /** A security context for grabbing the correct class loader. */
- private static final Security security
- = (Security) AccessController.doPrivileged(new PrivilegedAction()
- {
- // This will always work since java.util classes have (all) system
- // permissions.
- public Object run()
- {
- return new Security();
- }
- }
- );
-
- /**
* The resource bundle cache. This is a two-level hash map: The key
* is the class loader, the value is a new HashMap. The key of this
* second hash map is the localized name, the value is a soft
@@ -265,7 +223,7 @@
public static final ResourceBundle getBundle(String baseName)
{
return getBundle(baseName, Locale.getDefault(),
- security.getCallingClassLoader());
+ kaffe.lang.ThreadStack.getCallersClassLoader(true));
}
/**
@@ -283,7 +241,7 @@
public static final ResourceBundle getBundle(String baseName,
Locale locale)
{
- return getBundle(baseName, locale, security.getCallingClassLoader());
+ return getBundle(baseName, locale, kaffe.lang.ThreadStack.getCallersClassLoader(true));
}
/**
More information about the kaffe
mailing list