Finish the OutOfMemoryError implementation.
This copes with the double-OOME case.
Also check that I don't leave local references in a newly-attached thread's
local reference table, and fix the leaks this discovered.
Also fix the code that implements fillInNativeStackTrace to cope with the
situation where we're not able to allocate (because we're throwing
OutOfMemoryError and there's not enough space left for our arrays).
Also fix the order of checking for a pending exception and popping the
local references in the JNI native method invocation stub. (This fixes
the warnings we'd been seeing from the IndirectReferenceTable in test 064.)
Also improve some -Xcheck:jni output.
This fixes test 061.
Change-Id: Icc04a2c06339bd28d6772190350a86abfc5734b8
diff --git a/src/check_jni.cc b/src/check_jni.cc
index cb33d93..26068fd 100644
--- a/src/check_jni.cc
+++ b/src/check_jni.cc
@@ -268,13 +268,16 @@
return;
}
if (*expectedType != m->GetShorty()->CharAt(0)) {
- LOG(ERROR) << "JNI ERROR: expected return type '" << *expectedType << "' calling " << PrettyMethod(m);
+ LOG(ERROR) << "JNI ERROR: the return type of " << function_name_ << " does not match "
+ << PrettyMethod(m);
JniAbort();
} else if (isStatic && !m->IsStatic()) {
if (isStatic) {
- LOG(ERROR) << "JNI ERROR: calling non-static method " << PrettyMethod(m) << " with static call";
+ LOG(ERROR) << "JNI ERROR: calling non-static method "
+ << PrettyMethod(m) << " with " << function_name_;
} else {
- LOG(ERROR) << "JNI ERROR: calling static method " << PrettyMethod(m) << " with non-static call";
+ LOG(ERROR) << "JNI ERROR: calling static method "
+ << PrettyMethod(m) << " with non-static " << function_name_;
}
JniAbort();
}
@@ -723,7 +726,8 @@
* make any JNI calls other than the Exception* methods.
*/
if ((flags & kFlag_ExcepOkay) == 0 && self->IsExceptionPending()) {
- LOG(ERROR) << "JNI ERROR: JNI method called with exception pending";
+ LOG(ERROR) << "JNI ERROR: JNI " << function_name_ << " called with "
+ << PrettyTypeOf(self->GetException()) << " pending";
LOG(ERROR) << "Pending exception is:";
LOG(ERROR) << jniGetStackTrace(env_);
JniAbort();