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;
     }
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 2c683e9..9c00d72 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -1529,7 +1529,6 @@
 
   Thread* self = Thread::Current();
   ScopedThreadStateChange tsc(self, Thread::kRunnable);
-  LOG(INFO) << "initializing " << PrettyClass(c) << " from " << *self;
   c->MonitorEnter(self);
   InitializeClass(c, can_run_clinit);
   c->MonitorExit(self);
diff --git a/src/jni_internal_test.cc b/src/jni_internal_test.cc
index 725d9aa..74fdb0a 100644
--- a/src/jni_internal_test.cc
+++ b/src/jni_internal_test.cc
@@ -69,10 +69,6 @@
 }
 
 TEST_F(JniInternalTest, FindClass) {
-  // TODO: when these tests start failing because you're calling FindClass
-  // with a pending exception, fix EXPECT_CLASS_NOT_FOUND to assert that an
-  // exception was thrown and clear the exception.
-
   // Reference types...
   EXPECT_CLASS_FOUND("java/lang/String");
   // ...for arrays too, where you must include "L;".