Fix GetCurrentMethod to cope with callee-save frames.
We want to report something like this:
Aborting because JNI app bug detected (see above for details)
in call to Throw
from Main.throwNullPointerException()V
Rather than something like this:
Aborting because JNI app bug detected (see above for details)
in call to Throw
from java.lang.reflect.Method.$$$callee_save_method$$$()V
Change-Id: I84491c315dc0f114da1ab1fd9f191b5d04daf76e
diff --git a/src/thread.cc b/src/thread.cc
index e143af5..79dbf81 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -1245,6 +1245,20 @@
return result;
}
+const Method* Thread::GetCurrentMethod() const {
+ Method* m = top_of_managed_stack_.GetMethod();
+ // We use JNI internally for exception throwing, so it's possible to arrive
+ // here via a "FromCode" function, in which case there's a synthetic
+ // callee-save method at the top of the stack. These shouldn't be user-visible,
+ // so if we find one, skip it and return the compiled method underneath.
+ if (m->IsCalleeSaveMethod()) {
+ Frame f = top_of_managed_stack_;
+ f.Next();
+ m = f.GetMethod();
+ }
+ return m;
+}
+
bool Thread::HoldsLock(Object* object) {
if (object == NULL) {
return false;