Merge "ART: Do not JNI abort on nullptr GetObjectRefType" into lmp-mr1-dev
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index c11396f..2c8148f 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -2528,7 +2528,9 @@
   }
 
   static jobjectRefType GetObjectRefType(JNIEnv* env, jobject java_object) {
-    CHECK_NON_NULL_ARGUMENT_RETURN(java_object, JNIInvalidRefType);
+    if (java_object == nullptr) {
+      return JNIInvalidRefType;
+    }
 
     // Do we definitely know what kind of reference this is?
     IndirectRef ref = reinterpret_cast<IndirectRef>(java_object);
diff --git a/runtime/jni_internal_test.cc b/runtime/jni_internal_test.cc
index 8ae28cd..6bf14ce 100644
--- a/runtime/jni_internal_test.cc
+++ b/runtime/jni_internal_test.cc
@@ -1023,10 +1023,11 @@
 
   // TODO: invoke a native method and test that its arguments are considered local references.
 
-  // Null as object should fail.
-  CheckJniAbortCatcher jni_abort_catcher;
+  // 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) {