Check for null before using AddLocalReference in ti_method

We could incorrectly calling AddLocalReference with a null pointer
during the JVMTI GetLocalObject call. This would cause a check
failure because nulls are not allowed in the table.

Test: ./test.py --host
Test: Manual
Bug: 131856650
Change-Id: Iabc283061c8f3ca8b3f7421ef9de83bb67605402
(cherry picked from commit 023533677989028d48f4e64dad0a5b3b4e59b726)
diff --git a/openjdkjvmti/ti_method.cc b/openjdkjvmti/ti_method.cc
index bdbd7bc..a4b579b 100644
--- a/openjdkjvmti/ti_method.cc
+++ b/openjdkjvmti/ti_method.cc
@@ -691,7 +691,8 @@
         }
         art::JNIEnvExt* jni = art::Thread::Current()->GetJniEnv();
         art::ObjPtr<art::mirror::Object> obj(reinterpret_cast<art::mirror::Object*>(ptr_val));
-        ScopedLocalRef<jobject> local(jni, jni->AddLocalReference<jobject>(obj));
+        ScopedLocalRef<jobject> local(
+            jni, obj.IsNull() ? nullptr : jni->AddLocalReference<jobject>(obj));
         obj_val_ = jni->NewGlobalRef(local.get());
         break;
       }