Fix exception throwing to support no detail message.
(The empty string as a detail message is distinct from a NULL detail message,
and is treated differently by Throwable.printStackTrace.)
Change-Id: I8c65deac9f18c5782dcf6e72e4c37e6dd4174fe9
diff --git a/src/jni_internal_test.cc b/src/jni_internal_test.cc
index 74fdb0a..95e22ba 100644
--- a/src/jni_internal_test.cc
+++ b/src/jni_internal_test.cc
@@ -1360,9 +1360,17 @@
jclass exception_class = env_->FindClass("java/lang/RuntimeException");
ASSERT_TRUE(exception_class != NULL);
+ jthrowable thrown_exception;
+
EXPECT_EQ(JNI_OK, env_->ThrowNew(exception_class, "hello world"));
EXPECT_TRUE(env_->ExceptionCheck());
- jthrowable thrown_exception = env_->ExceptionOccurred();
+ thrown_exception = env_->ExceptionOccurred();
+ env_->ExceptionClear();
+ EXPECT_TRUE(env_->IsInstanceOf(thrown_exception, exception_class));
+
+ EXPECT_EQ(JNI_OK, env_->ThrowNew(exception_class, NULL));
+ EXPECT_TRUE(env_->ExceptionCheck());
+ thrown_exception = env_->ExceptionOccurred();
env_->ExceptionClear();
EXPECT_TRUE(env_->IsInstanceOf(thrown_exception, exception_class));
}