Dump the pending exception when CheckJNI spots a call to a function that requires there to be no pending exception.
Change-Id: Ice81e23c408ce15902a6270c8835ceabb0e5e278
diff --git a/src/check_jni.cc b/src/check_jni.cc
index 8a8862d..6ff0fd7 100644
--- a/src/check_jni.cc
+++ b/src/check_jni.cc
@@ -25,6 +25,10 @@
#include "thread.h"
#include "runtime.h"
+#define LIBCORE_CPP_JNI_HELPERS
+#include <JNIHelp.h> // from libcore
+#undef LIBCORE_CPP_JNI_HELPERS
+
namespace art {
void JniAbort(const char* jni_function_name) {
@@ -32,7 +36,7 @@
const Method* current_method = self->GetCurrentMethod();
std::stringstream os;
- os << "JNI app bug detected";
+ os << "Aborting because JNI app bug detected (see above for details)";
if (jni_function_name != NULL) {
os << "\n in call to " << jni_function_name;
@@ -678,8 +682,8 @@
*/
if ((flags & kFlag_ExcepOkay) == 0 && self->IsExceptionPending()) {
LOG(ERROR) << "JNI ERROR: JNI method called with exception pending";
- LOG(ERROR) << "Pending exception is: TODO"; // TODO
- // TODO: dvmLogExceptionStackTrace();
+ LOG(ERROR) << "Pending exception is:";
+ LOG(ERROR) << jniGetStackTrace(mEnv);
JniAbort();
return;
}