summaryrefslogtreecommitdiffstats
path: root/libjava/java/lang
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-06 08:34:58 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-06 08:34:58 +0000
commit6c1c0b9f11178e0b3a2742de81a22d10ee2a9871 (patch)
treef3b23a77c72b7ec64fcadda0eeb7832c2f9626b5 /libjava/java/lang
parentada8cf8b54c4a5850540833a4a089c7bed36d1fe (diff)
downloadppe42-gcc-6c1c0b9f11178e0b3a2742de81a22d10ee2a9871.tar.gz
ppe42-gcc-6c1c0b9f11178e0b3a2742de81a22d10ee2a9871.zip
2004-01-06 Michael Koch <konqueror@gmx.de>
* java/lang/Package.java (getPackage): Get the current class loader directly. * java/lang/SecurityManager.java (currentLoadedClass): Dont iterate over class contexts. (classLoaderDepth): Don't check class loaders if everything is allowed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75465 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang')
-rw-r--r--libjava/java/lang/Package.java3
-rw-r--r--libjava/java/lang/SecurityManager.java24
2 files changed, 16 insertions, 11 deletions
diff --git a/libjava/java/lang/Package.java b/libjava/java/lang/Package.java
index f09814b6764..3045b50c2f1 100644
--- a/libjava/java/lang/Package.java
+++ b/libjava/java/lang/Package.java
@@ -269,8 +269,7 @@ public class Package
public static Package getPackage(String name)
{
// Get the caller's classloader
- Class c = VMSecurityManager.getClassContext()[1];
- ClassLoader cl = c.getClassLoader();
+ ClassLoader cl = VMSecurityManager.currentClassLoader();
return cl != null ? cl.getPackage(name) : null;
}
diff --git a/libjava/java/lang/SecurityManager.java b/libjava/java/lang/SecurityManager.java
index e54ebc62f70..bec39de1cd4 100644
--- a/libjava/java/lang/SecurityManager.java
+++ b/libjava/java/lang/SecurityManager.java
@@ -207,11 +207,8 @@ public class SecurityManager
*/
protected Class currentLoadedClass()
{
- Class[] c = getClassContext();
- for (int i = 0; i < c.length; i++)
- if (c[i].getClassLoader() != null)
- return c[i];
- return null;
+ int i = classLoaderDepth();
+ return i >= 0 ? getClassContext()[i] : null;
}
/**
@@ -247,10 +244,18 @@ public class SecurityManager
*/
protected int classLoaderDepth()
{
- Class[] c = getClassContext();
- for (int i = 0; i < c.length; i++)
- if (c[i].getClassLoader() != null)
- return i;
+ try
+ {
+ checkPermission(new AllPermission());
+ }
+ catch (SecurityException e)
+ {
+ Class[] c = getClassContext();
+ for (int i = 0; i < c.length; i++)
+ if (c[i].getClassLoader() != null)
+ // XXX Check if c[i] is AccessController, or a system class.
+ return i;
+ }
return -1;
}
@@ -1016,6 +1021,7 @@ public class SecurityManager
for (int index = list.indexOf(packageName);
index != -1; index = list.indexOf(packageName, index + 1))
{
+ // Exploit package visibility for speed.
int packageNameCount = packageName.length();
if (index + packageNameCount == list.length()
|| list.charAt(index + packageNameCount) == ',')
OpenPOWER on IntegriCloud