diff options
author | Corey Minyard <minyard@acm.org> | 2001-09-05 17:48:18 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2001-09-05 17:48:18 +0000 |
commit | c946ec44f8df9914de1f6719db783a2b62be4fd7 (patch) | |
tree | 883d30c25b30bb57d4b45b846e61dc39052a33ec | |
parent | c1a13c5f88996b26641bde1dbfb7b0e47dccfc51 (diff) | |
download | gcc-c946ec44f8df9914de1f6719db783a2b62be4fd7.zip gcc-c946ec44f8df9914de1f6719db783a2b62be4fd7.tar.gz gcc-c946ec44f8df9914de1f6719db783a2b62be4fd7.tar.bz2 |
natClassLoader.cc: Include VirtualMachineError.h
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.
Co-Authored-By: Tom Tromey <tromey@redhat.com>
From-SVN: r45418
-rw-r--r-- | libjava/ChangeLog | 7 | ||||
-rw-r--r-- | libjava/java/lang/natClassLoader.cc | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 0d0c66b..e867cbf 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -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 diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index 890a4a7..70dea6d 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -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; } |