From 7a3155bef708a70dfa72958ef23fc2356b20c8a2 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Fri, 23 Mar 2001 16:21:24 -0800 Subject: [PATCH] natClass.cc (_Jv_IsAssignableFrom): Checking the ancestors array is invalid for interfaces... * java/lang/natClass.cc (_Jv_IsAssignableFrom): Checking the ancestors array is invalid for interfaces, so do that *after* check that the target type is not an interface. From-SVN: r40797 --- libjava/ChangeLog | 6 ++++++ libjava/java/lang/natClass.cc | 17 ++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 5c24dd98221..e8d5d614ccc 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2001-03-23 Per Bothner + + * java/lang/natClass.cc (_Jv_IsAssignableFrom): Checking the + ancestors array is invalid for interfaces, so do that *after* + check that the target type is not an interface. + 2000-03-23 Jeff Sturm * prims.cc (_Jv_FindClassFromSignature): Check return of diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc index b934ae76389..5d7497109af 100644 --- a/libjava/java/lang/natClass.cc +++ b/libjava/java/lang/natClass.cc @@ -909,11 +909,8 @@ _Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface, int method_idx) jboolean _Jv_IsAssignableFrom (jclass target, jclass source) { - if (source == target - || (target == &ObjectClass && !source->isPrimitive()) - || (source->ancestors != NULL - && source->ancestors[source->depth - target->depth] == target)) - return true; + if (source == target) + return true; // If target is array, so must source be. if (target->isArray ()) @@ -945,9 +942,15 @@ _Jv_IsAssignableFrom (jclass target, jclass source) && cl_idt->cls.itable[offset] == target) return true; } + return false; } - - return false; + + if ((target == &ObjectClass && !source->isPrimitive()) + || (source->ancestors != NULL + && source->ancestors[source->depth - target->depth] == target)) + return true; + + return false; } // Interface type checking, the slow way. Returns TRUE if IFACE is a -- 2.30.2