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
This commit is contained in:
Bryce McKinlay 2006-05-17 15:09:57 +00:00 committed by Bryce McKinlay
parent c93c502529
commit 5600ef7fb1
2 changed files with 26 additions and 7 deletions

View File

@ -1,3 +1,13 @@
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>
* stacktrace.cc (StackTrace::FillInFrameInfo): Use

View File

@ -115,7 +115,7 @@ public final class Class implements Serializable
private static Class forName (String className, Class caller)
throws ClassNotFoundException
{
return forName(className, true, caller.getClassLoader());
return forName(className, true, caller.getClassLoaderInternal());
}
@ -192,10 +192,19 @@ public final class Class implements Serializable
* @see RuntimePermission
*/
public native ClassLoader getClassLoader ();
// A private internal method that is called by compiler-generated code.
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.
* Examples: "[[Ljava.lang.String;" would return "[Ljava.lang.String;", and
@ -473,7 +482,7 @@ public final class Class implements Serializable
*/
public Package getPackage()
{
ClassLoader cl = getClassLoader();
ClassLoader cl = getClassLoaderInternal();
if (cl != null)
return cl.getPackage(getPackagePortion(getName()));
else
@ -616,7 +625,7 @@ public final class Class implements Serializable
public URL getResource(String resourceName)
{
String name = resourcePath(resourceName);
ClassLoader loader = getClassLoader();
ClassLoader loader = getClassLoaderInternal();
if (loader == null)
return ClassLoader.getSystemResource(name);
return loader.getResource(name);
@ -644,7 +653,7 @@ public final class Class implements Serializable
public InputStream getResourceAsStream(String resourceName)
{
String name = resourcePath(resourceName);
ClassLoader loader = getClassLoader();
ClassLoader loader = getClassLoaderInternal();
if (loader == null)
return ClassLoader.getSystemResourceAsStream(name);
return loader.getResourceAsStream(name);
@ -839,7 +848,7 @@ public final class Class implements Serializable
*/
public boolean desiredAssertionStatus()
{
ClassLoader c = getClassLoader();
ClassLoader c = getClassLoaderInternal();
Object status;
if (c == null)
return VMClassLoader.defaultAssertionStatus();