summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-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 083f179f38..0624281c20 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 d255ec8dff..d50e094627 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));