Add -Xcheck:jni.
I think this is as complete as possible right now. The remaining
two #if 0 sections require:
1. a way to get the Method* of the current native method.
2. a way to get the Class* of the type of a given Field*.
Change-Id: I331586022095fb36ccc10c9ac1890a59a9224d01
diff --git a/src/thread.cc b/src/thread.cc
index 525e2a1..c90c745 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -303,16 +303,18 @@
// Assume an invalid local reference is actually a direct pointer.
result = reinterpret_cast<Object*>(obj);
} else {
- LOG(FATAL) << "Invalid indirect reference " << obj;
- result = reinterpret_cast<Object*>(kInvalidIndirectRefObject);
+ result = kInvalidIndirectRefObject;
}
}
if (result == NULL) {
- LOG(FATAL) << "JNI ERROR (app bug): use of deleted " << kind << ": "
- << obj;
+ LOG(ERROR) << "JNI ERROR (app bug): use of deleted " << kind << ": " << obj;
+ JniAbort(NULL);
+ } else {
+ if (result != kInvalidIndirectRefObject) {
+ Heap::VerifyObject(result);
+ }
}
- Heap::VerifyObject(result);
return result;
}