From 125fe3440ec8f4841471e957164715af4918d412 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 21 Jan 2008 16:42:12 -0700 Subject: [PATCH] allow java.lang.Object with no virtual methods, which may occur due to code shrinking --- src/machine.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index 36c7780bb8..d446d7384e 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1347,16 +1347,23 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool) if (declaredVirtualCount == 0 and (classFlags(t, class_) & ACC_INTERFACE) == 0) { - // inherit virtual table from superclass - set(t, class_, ClassVirtualTable, superVirtualTable); - - if (classInterfaceTable(t, classSuper(t, class_)) - and arrayLength(t, classInterfaceTable(t, class_)) - == arrayLength(t, classInterfaceTable(t, classSuper(t, class_)))) - { - // inherit interface table from superclass - set(t, class_, ClassInterfaceTable, - classInterfaceTable(t, classSuper(t, class_))); + if (classSuper(t, class_)) { + // inherit virtual table from superclass + set(t, class_, ClassVirtualTable, superVirtualTable); + + if (classInterfaceTable(t, classSuper(t, class_)) + and arrayLength(t, classInterfaceTable(t, class_)) + == arrayLength(t, classInterfaceTable(t, classSuper(t, class_)))) + { + // inherit interface table from superclass + set(t, class_, ClassInterfaceTable, + classInterfaceTable(t, classSuper(t, class_))); + } + } else { + // apparently Object does not have any virtual methods. We give + // it a vtable anyway so code doesn't break elsewhere. + object vtable = makeArray(t, 0, false); + set(t, class_, ClassVirtualTable, vtable); } } else if (virtualCount) { // generate class vtable