OSDN Git Service

2001-09-05 Corey Minyard <minyard@acm.org>
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Sep 2001 17:48:18 +0000 (17:48 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Sep 2001 17:48:18 +0000 (17:48 +0000)
    Tom Tromey  <tromey@redhat.com>

* java/lang/natClassLoader.cc: Include VirtualMachineError.h
(_Jv_RegisterClassHookDefault): Throw error if a class is
registered twice.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45418 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/lang/natClassLoader.cc

index 0d0c66b..e867cbf 100644 (file)
@@ -1,3 +1,10 @@
+2001-09-05  Corey Minyard  <minyard@acm.org>
+           Tom Tromey  <tromey@redhat.com>
+
+       * java/lang/natClassLoader.cc: Include VirtualMachineError.h
+       (_Jv_RegisterClassHookDefault): Throw error if a class is
+       registered twice.
+
 2001-09-05  Tom Tromey  <tromey@redhat.com>
 
        * java/lang/natSystem.cc (init_properties): Default locale is
index 890a4a7..70dea6d 100644 (file)
@@ -33,6 +33,7 @@ details.  */
 #include <java/lang/ClassNotFoundException.h>
 #include <java/lang/ClassCircularityError.h>
 #include <java/lang/IncompatibleClassChangeError.h>
+#include <java/lang/VirtualMachineError.h>
 #include <java/lang/reflect/Modifier.h>
 #include <java/lang/Runtime.h>
 #include <java/lang/StringBuffer.h>
@@ -453,6 +454,22 @@ void
 _Jv_RegisterClassHookDefault (jclass klass)
 {
   jint hash = HASH_UTF (klass->name);
+
+  jclass check_class = loaded_classes[hash];
+
+  // If the class is already registered, don't re-register it.
+  while (check_class != NULL)
+    {
+      if (check_class == klass)
+       {
+         // If you get this, it means you have the same class in two
+         // different libraries.
+         throw new java::lang::VirtualMachineError (JvNewStringLatin1 ("class registered twice"));
+       }
+
+      check_class = check_class->next;
+    }
+
   klass->next = loaded_classes[hash];
   loaded_classes[hash] = klass;
 }