Fix the detail messages for NoSuchMethodErrors thrown from generated code.
Change-Id: Ice525a5352fe66bf13d44752c59d3994b8bdfe97
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index 57f216d..89dac70 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -208,6 +208,7 @@
*sp = runtime->GetCalleeSaveMethod();
self->SetTopOfStack(sp, 0);
+ // We need the calling method as context to interpret 'ref'.
Frame frame = self->GetTopOfStack();
frame.Next();
Method* method = frame.GetMethod();
@@ -282,14 +283,20 @@
thread->DeliverException();
}
-extern "C" void artThrowNoSuchMethodFromCode(int32_t method_idx, Thread* thread, Method** sp) {
+extern "C" void artThrowNoSuchMethodFromCode(int32_t method_idx, Thread* self, Method** sp) {
// Place a special frame at the TOS that will save all callee saves
Runtime* runtime = Runtime::Current();
*sp = runtime->GetCalleeSaveMethod();
- thread->SetTopOfStack(sp, 0);
- LOG(WARNING) << "TODO: no such method exception detail message. method_idx=" << method_idx;
- thread->ThrowNewExceptionF("Ljava/lang/NoSuchMethodError;", "method_idx=%d", method_idx);
- thread->DeliverException();
+ self->SetTopOfStack(sp, 0);
+
+ // We need the calling method as context for the method_idx.
+ Frame frame = self->GetTopOfStack();
+ frame.Next();
+ Method* method = frame.GetMethod();
+
+ self->ThrowNewException("Ljava/lang/NoSuchMethodError;",
+ MethodNameFromIndex(method, method_idx, DexVerifier::VERIFY_ERROR_REF_METHOD, false).c_str());
+ self->DeliverException();
}
extern "C" void artThrowNegArraySizeFromCode(int32_t size, Thread* thread, Method** sp) {