diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 0d0c66b5319..e867cbfcf7b 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2001-09-05 Corey Minyard + Tom Tromey + + * java/lang/natClassLoader.cc: Include VirtualMachineError.h + (_Jv_RegisterClassHookDefault): Throw error if a class is + registered twice. + 2001-09-05 Tom Tromey * java/lang/natSystem.cc (init_properties): Default locale is diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index 890a4a7d879..70dea6db84a 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -33,6 +33,7 @@ details. */ #include #include #include +#include #include #include #include @@ -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; }