Commit 5600ef7f by Bryce McKinlay Committed by Bryce McKinlay

re PR libgcj/27352 (SecurityManager.checkPermission() called unnecessarily)

        PR libgcj/27352
        * java/lang/Class.java (getClassLoaderInternal): New method.
        (forName (String, Class)): Use getClassLoaderInternal.
        (getPackage): Likewise.
        (getResource): Likewise.
        (getResourceAsStream): Likewise.
        (desiredAssertionStatus): Likewise.

From-SVN: r113863
parent c93c5025
2006-05-15 Bryce McKinlay <mckinlay@redhat.com>
PR libgcj/27352
* java/lang/Class.java (getClassLoaderInternal): New method.
(forName (String, Class)): Use getClassLoaderInternal.
(getPackage): Likewise.
(getResource): Likewise.
(getResourceAsStream): Likewise.
(desiredAssertionStatus): Likewise.
2006-05-15 Andreas Tobler <a.tobler@schweiz.ch> 2006-05-15 Andreas Tobler <a.tobler@schweiz.ch>
* stacktrace.cc (StackTrace::FillInFrameInfo): Use * stacktrace.cc (StackTrace::FillInFrameInfo): Use
......
...@@ -115,7 +115,7 @@ public final class Class implements Serializable ...@@ -115,7 +115,7 @@ public final class Class implements Serializable
private static Class forName (String className, Class caller) private static Class forName (String className, Class caller)
throws ClassNotFoundException throws ClassNotFoundException
{ {
return forName(className, true, caller.getClassLoader()); return forName(className, true, caller.getClassLoaderInternal());
} }
...@@ -197,6 +197,15 @@ public final class Class implements Serializable ...@@ -197,6 +197,15 @@ public final class Class implements Serializable
private final native ClassLoader getClassLoader (Class caller); private final native ClassLoader getClassLoader (Class caller);
/** /**
* Internal method that circumvents the usual security checks when
* getting the class loader.
*/
private ClassLoader getClassLoaderInternal ()
{
return loader;
}
/**
* If this is an array, get the Class representing the type of array. * If this is an array, get the Class representing the type of array.
* Examples: "[[Ljava.lang.String;" would return "[Ljava.lang.String;", and * Examples: "[[Ljava.lang.String;" would return "[Ljava.lang.String;", and
* calling getComponentType on that would give "java.lang.String". If * calling getComponentType on that would give "java.lang.String". If
...@@ -473,7 +482,7 @@ public final class Class implements Serializable ...@@ -473,7 +482,7 @@ public final class Class implements Serializable
*/ */
public Package getPackage() public Package getPackage()
{ {
ClassLoader cl = getClassLoader(); ClassLoader cl = getClassLoaderInternal();
if (cl != null) if (cl != null)
return cl.getPackage(getPackagePortion(getName())); return cl.getPackage(getPackagePortion(getName()));
else else
...@@ -616,7 +625,7 @@ public final class Class implements Serializable ...@@ -616,7 +625,7 @@ public final class Class implements Serializable
public URL getResource(String resourceName) public URL getResource(String resourceName)
{ {
String name = resourcePath(resourceName); String name = resourcePath(resourceName);
ClassLoader loader = getClassLoader(); ClassLoader loader = getClassLoaderInternal();
if (loader == null) if (loader == null)
return ClassLoader.getSystemResource(name); return ClassLoader.getSystemResource(name);
return loader.getResource(name); return loader.getResource(name);
...@@ -644,7 +653,7 @@ public final class Class implements Serializable ...@@ -644,7 +653,7 @@ public final class Class implements Serializable
public InputStream getResourceAsStream(String resourceName) public InputStream getResourceAsStream(String resourceName)
{ {
String name = resourcePath(resourceName); String name = resourcePath(resourceName);
ClassLoader loader = getClassLoader(); ClassLoader loader = getClassLoaderInternal();
if (loader == null) if (loader == null)
return ClassLoader.getSystemResourceAsStream(name); return ClassLoader.getSystemResourceAsStream(name);
return loader.getResourceAsStream(name); return loader.getResourceAsStream(name);
...@@ -839,7 +848,7 @@ public final class Class implements Serializable ...@@ -839,7 +848,7 @@ public final class Class implements Serializable
*/ */
public boolean desiredAssertionStatus() public boolean desiredAssertionStatus()
{ {
ClassLoader c = getClassLoader(); ClassLoader c = getClassLoaderInternal();
Object status; Object status;
if (c == null) if (c == null)
return VMClassLoader.defaultAssertionStatus(); return VMClassLoader.defaultAssertionStatus();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment