+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
private static Class forName (String className, Class caller)
throws ClassNotFoundException
{
- return forName(className, true, caller.getClassLoader());
+ return forName(className, true, caller.getClassLoaderInternal());
}
* @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
*/
public Package getPackage()
{
- ClassLoader cl = getClassLoader();
+ ClassLoader cl = getClassLoaderInternal();
if (cl != null)
return cl.getPackage(getPackagePortion(getName()));
else
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);
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);
*/
public boolean desiredAssertionStatus()
{
- ClassLoader c = getClassLoader();
+ ClassLoader c = getClassLoaderInternal();
Object status;
if (c == null)
return VMClassLoader.defaultAssertionStatus();