From 5db31b59401d6a1452f5cf3f714f45014d6cb2d7 Mon Sep 17 00:00:00 2001 From: Graham Chapman Date: Thu, 15 Feb 2018 18:10:51 -0500 Subject: [PATCH] Revert "Revert "Allow Object methods in invokeinterface"" --- runtime/vm/resolvesupport.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime/vm/resolvesupport.cpp b/runtime/vm/resolvesupport.cpp index 2b425727f9a..8b39e2eefeb 100644 --- a/runtime/vm/resolvesupport.cpp +++ b/runtime/vm/resolvesupport.cpp @@ -1005,8 +1005,18 @@ resolveInterfaceMethodRefInto(J9VMThread *vmStruct, J9ConstantPool *ramCP, UDATA if (method != NULL) { if (ramCPEntry != NULL) { J9RAMInterfaceMethodRef *ramInterfaceMethodRef = (J9RAMInterfaceMethodRef *)&ramCP[cpIndex]; - UDATA methodIndex = getITableIndexForMethod(method, interfaceClass) << 8; + J9Class *methodClass = J9_CLASS_FROM_METHOD(method); + UDATA methodIndex = 0; UDATA oldArgCount = ramInterfaceMethodRef->methodIndexAndArgCount & 255; + /* Object methods may be invoked via invokeinterface. In that case, use Object + * for the interfaceClass in the ref. The methodIndex value doesn't matter as + * Object will never be found in an iTable. + */ + if (J9_ARE_ANY_BITS_SET(methodClass->romClass->modifiers, J9_JAVA_INTERFACE)) { + methodIndex = getITableIndexForMethod(method, interfaceClass) << 8; + } else { + interfaceClass = methodClass; + } methodIndex |= oldArgCount; ramCPEntry->methodIndexAndArgCount = methodIndex; /* interfaceClass is used to indicate resolved. Make sure to write it last */