fix handling of interfaces in isAssignableFrom

The old version was both incorrect (in the case where both arguments
are interfaces) and inefficient.
This commit is contained in:
Joel Dice 2011-04-09 21:09:59 -06:00
parent 948a2523f1
commit b3d65fab9b

View File

@ -3176,13 +3176,12 @@ isAssignableFrom(Thread* t, object a, object b)
}
}
for (; b; b = classSuper(t, b)) {
object itable = classInterfaceTable(t, b);
if (itable) {
for (unsigned i = 0; i < arrayLength(t, itable); i += 2) {
if (arrayBody(t, itable, i) == a) {
return true;
}
object itable = classInterfaceTable(t, b);
if (itable) {
unsigned stride = (classFlags(t, b) & ACC_INTERFACE) ? 1 : 2;
for (unsigned i = 0; i < arrayLength(t, itable); i += stride) {
if (arrayBody(t, itable, i) == a) {
return true;
}
}
}