summaryrefslogtreecommitdiffstats
path: root/runtime/jni_internal.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2014-10-06 22:42:03 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-06 22:42:03 +0000
commit233806ee44f43fd1e296372458c3009ac061c76a (patch)
treea7281536d6680342b42520583deac846ff9c4ca4 /runtime/jni_internal.cc
parent756f65262c69acce6c85f55ab69aedac8ac05df7 (diff)
parent902c989bc46da80c3c80e49c7f868b63ba73d2de (diff)
downloadart-233806ee44f43fd1e296372458c3009ac061c76a.tar.gz
art-233806ee44f43fd1e296372458c3009ac061c76a.tar.bz2
art-233806ee44f43fd1e296372458c3009ac061c76a.zip
am 902c989b: Merge "Add way to warn about missing JNI_ABORT"
* commit '902c989bc46da80c3c80e49c7f868b63ba73d2de': Add way to warn about missing JNI_ABORT
Diffstat (limited to 'runtime/jni_internal.cc')
-rw-r--r--runtime/jni_internal.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index e2f9ac2b05..0bc519e64a 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -57,6 +57,10 @@
namespace art {
+// Consider turning this on when there is errors which could be related to JNI array copies such as
+// things not rendering correctly. E.g. b/16858794
+static constexpr bool kWarnJniAbort = false;
+
// Section 12.3.2 of the JNI spec describes JNI class descriptors. They're
// separated with slashes but aren't wrapped with "L;" like regular descriptors
// (i.e. "a/b/C" rather than "La/b/C;"). Arrays of reference types are an
@@ -2376,10 +2380,13 @@ class JNI {
reinterpret_cast<void*>(elements), array_data);
return;
}
- }
- // Don't need to copy if we had a direct pointer.
- if (mode != JNI_ABORT && is_copy) {
- memcpy(array_data, elements, bytes);
+ if (mode != JNI_ABORT) {
+ memcpy(array_data, elements, bytes);
+ } else if (kWarnJniAbort && memcmp(array_data, elements, bytes) != 0) {
+ // Warn if we have JNI_ABORT and the arrays don't match since this is usually an error.
+ LOG(WARNING) << "Possible incorrect JNI_ABORT in Release*ArrayElements";
+ soa.Self()->DumpJavaStack(LOG(WARNING));
+ }
}
if (mode != JNI_COMMIT) {
if (is_copy) {