diff options
author | Andreas Gampe <agampe@google.com> | 2014-12-20 00:08:35 -0800 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-12-22 09:41:54 -0800 |
commit | a87630724ef4f8760684fa69c8ecc685735aff88 (patch) | |
tree | 516aae0158dae68f79504a66b5dc417c5817c510 /runtime/jni_internal_test.cc | |
parent | 6d1a047b4b3f9707d4ee1cc19e99717ee021ef48 (diff) | |
download | android_art-a87630724ef4f8760684fa69c8ecc685735aff88.tar.gz android_art-a87630724ef4f8760684fa69c8ecc685735aff88.tar.bz2 android_art-a87630724ef4f8760684fa69c8ecc685735aff88.zip |
ART: Do not JNI abort on nullptr GetObjectRefType
A nullptr is a valid input, as it is different from a null reference.
Bug: 18820997
Change-Id: Ibda8907ba13b20d2055049492a356ffdf4ddc714
Diffstat (limited to 'runtime/jni_internal_test.cc')
-rw-r--r-- | runtime/jni_internal_test.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime/jni_internal_test.cc b/runtime/jni_internal_test.cc index 045fe2f811..8e329687c4 100644 --- a/runtime/jni_internal_test.cc +++ b/runtime/jni_internal_test.cc @@ -1300,16 +1300,20 @@ TEST_F(JniInternalTest, GetObjectRefType) { jweak weak_global = env_->NewWeakGlobalRef(local); EXPECT_EQ(JNIWeakGlobalRefType, env_->GetObjectRefType(weak_global)); - CheckJniAbortCatcher jni_abort_catcher; - jobject invalid = reinterpret_cast<jobject>(this); - EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(invalid)); - jni_abort_catcher.Check("use of invalid jobject"); + { + CheckJniAbortCatcher jni_abort_catcher; + jobject invalid = reinterpret_cast<jobject>(this); + EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(invalid)); + jni_abort_catcher.Check("use of invalid jobject"); + } // TODO: invoke a native method and test that its arguments are considered local references. - // Null as object should fail. + // Null as pointer should not fail and return invalid-ref. b/18820997 EXPECT_EQ(JNIInvalidRefType, env_->GetObjectRefType(nullptr)); - jni_abort_catcher.Check("java_object == null"); + + // TODO: Null as reference should return the original type. + // This requires running a GC so a non-null object gets freed. } TEST_F(JniInternalTest, StaleWeakGlobal) { |