Some tests are calling ExceptionDescribe without checking if
we have an exception occurred. The most JVM's like Dalvik can
handle this in a good way, but art crashes with JNI error.
This adds a check in art::ExceptionDescribe for a case when it
called without exception.
Change-Id: Id9eddcc73e78b1197109be5a6340f9ff60940c74
Signed-off-by: Alexei Zavjalov <alexei.zavjalov@intel.com>
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));
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));