summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-07-02 15:27:18 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-07-01 19:26:36 +0000
commitbcf40221d747c05be7cb78d92a20caff240291d5 (patch)
tree72d23fbab3a794f8655579b0329c20dccbbecd66
parent395fa7286ca2c6cd3dd55c0eab5b0f69dc063fb8 (diff)
parent3a1444ccb92fb1b11d4943c3baa1f0a3abed4f10 (diff)
downloadart-bcf40221d747c05be7cb78d92a20caff240291d5.zip
art-bcf40221d747c05be7cb78d92a20caff240291d5.tar.gz
art-bcf40221d747c05be7cb78d92a20caff240291d5.tar.bz2
Merge "ART: JNI ExceptionDescribe crashes if no exception occurred"
-rw-r--r--runtime/jni_internal.cc5
-rw-r--r--runtime/jni_internal_test.cc6
2 files changed, 11 insertions, 0 deletions
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index 083f179..0624281 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -684,6 +684,11 @@ class JNI {
static void ExceptionDescribe(JNIEnv* env) {
ScopedObjectAccess soa(env);
+ // If we have no exception to describe, pass through.
+ if (!soa.Self()->GetException(nullptr)) {
+ return;
+ }
+
StackHandleScope<3> hs(soa.Self());
// TODO: Use nullptr instead of null handles?
auto old_throw_this_object(hs.NewHandle<mirror::Object>(nullptr));
diff --git a/runtime/jni_internal_test.cc b/runtime/jni_internal_test.cc
index d255ec8..d50e094 100644
--- a/runtime/jni_internal_test.cc
+++ b/runtime/jni_internal_test.cc
@@ -1472,6 +1472,12 @@ TEST_F(JniInternalTest, DeleteWeakGlobalRef) {
env_->DeleteWeakGlobalRef(o2);
}
+TEST_F(JniInternalTest, ExceptionDescribe) {
+ // This checks how ExceptionDescribe handles call without exception.
+ env_->ExceptionClear();
+ env_->ExceptionDescribe();
+}
+
TEST_F(JniInternalTest, Throw) {
EXPECT_EQ(JNI_ERR, env_->Throw(nullptr));