]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libgcj/2428 (Classloader is not set)
authorTom Tromey <tromey@redhat.com>
Fri, 21 Dec 2001 19:47:50 +0000 (19:47 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Fri, 21 Dec 2001 19:47:50 +0000 (19:47 +0000)
Fix for PR libgcj/2428:
* java/lang/natClass.cc: Include RuntimePermission.h.
(getClassLoader): Define.
* java/lang/Class.h (Class.getClassLoader): Only declare.

From-SVN: r48253

libjava/ChangeLog
libjava/java/lang/Class.h
libjava/java/lang/natClass.cc

index 3513b273f6e63215d78c868c2165300a8710cc66..a9ce3528f8ce0ae0e1c0035c4e20e294a88e4cb1 100644 (file)
@@ -1,3 +1,10 @@
+2001-12-21  Tom Tromey  <tromey@redhat.com>
+
+       Fix for PR libgcj/2428:
+       * java/lang/natClass.cc: Include RuntimePermission.h.
+       (getClassLoader): Define.
+       * java/lang/Class.h (Class.getClassLoader): Only declare.
+
 2001-12-19  Tom Tromey  <tromey@redhat.com>
 
        * java/awt/FlowLayout.java (FlowLayout(), FlowLayout(int)): Set
index 73d81daad165275d26ed8c8265e5e0ed20645bed..0f36f25eacf2640b1296381ed0bc32eeecabc571 100644 (file)
@@ -134,10 +134,7 @@ public:
   static jclass forName (jstring className);
   JArray<jclass> *getClasses (void);
 
-  java::lang::ClassLoader *getClassLoader (void)
-    {
-      return loader;
-    }
+  java::lang::ClassLoader *getClassLoader (void);
 
   java::lang::reflect::Constructor *getConstructor (JArray<jclass> *);
   JArray<java::lang::reflect::Constructor *> *getConstructors (void);
index 6dfe14bab717360140cb69b44dbb0eb8d75a3a4d..0e34f323eb44dc7f3af68f332fefa15a930d3e73 100644 (file)
@@ -43,6 +43,7 @@ details.  */
 #include <java/lang/NoSuchMethodException.h>
 #include <java/lang/Thread.h>
 #include <java/lang/NullPointerException.h>
+#include <java/lang/RuntimePermission.h>
 #include <java/lang/System.h>
 #include <java/lang/SecurityManager.h>
 #include <java/lang/StringBuffer.h>
@@ -102,6 +103,29 @@ java::lang::Class::forName (jstring className)
   return forName (className, true, NULL);
 }
 
+java::lang::ClassLoader *
+java::lang::Class::getClassLoader (void)
+{
+#if 0
+  // FIXME: the checks we need to do are more complex.  See the spec.
+  // Currently we can't implement them.
+  java::lang::SecurityManager *s = java::lang::System::getSecurityManager();
+  if (s != NULL)
+    s->checkPermission (new RuntimePermission (JvNewStringLatin1 ("getClassLoader")));
+#endif
+
+  // The spec requires us to return `null' for primitive classes.  In
+  // other cases we have the option of returning `null' for classes
+  // loaded with the bootstrap loader.  All gcj-compiled classes which
+  // are linked into the application used to return `null' here, but
+  // that confuses some poorly-written applications.  It is a useful
+  // and apparently harmless compatibility hack to simply never return
+  // `null' instead.
+  if (isPrimitive ())
+    return NULL;
+  return loader ? loader : ClassLoader::getSystemClassLoader ();
+}
+
 java::lang::reflect::Constructor *
 java::lang::Class::getConstructor (JArray<jclass> *param_types)
 {
@@ -373,6 +397,8 @@ java::lang::Class::getName (void)
 JArray<jclass> *
 java::lang::Class::getClasses (void)
 {
+  // FIXME: security checking.
+
   // Until we have inner classes, it always makes sense to return an
   // empty array.
   JArray<jclass> *result
@@ -440,6 +466,8 @@ java::lang::Class::_getFields (JArray<java::lang::reflect::Field *> *result,
 JArray<java::lang::reflect::Field *> *
 java::lang::Class::getFields (void)
 {
+  // FIXME: security checking.
+
   using namespace java::lang::reflect;
 
   int count = _getFields (NULL, 0);