Allow null current thread in jni weak ref decode during shutdown.

Fix a crash during a runtime shutdown for the read barrier config.

Bug: 23897251
Bug: 12687968
Change-Id: Iea0888cb6d052d4becddba289dc0ed121461e97d
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index 92eef39..63e8887 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -580,9 +580,12 @@
 }
 
 inline bool JavaVMExt::MayAccessWeakGlobalsUnlocked(Thread* self) const {
-  return kUseReadBarrier
-      ? self->GetWeakRefAccessEnabled()
-      : allow_accessing_weak_globals_.LoadSequentiallyConsistent();
+  if (kUseReadBarrier) {
+    // self can be null during a runtime shutdown. ~Runtime()->~ClassLinker()->DecodeWeakGlobal().
+    return self != nullptr ? self->GetWeakRefAccessEnabled() : true;
+  } else {
+    return allow_accessing_weak_globals_.LoadSequentiallyConsistent();
+  }
 }
 
 mirror::Object* JavaVMExt::DecodeWeakGlobal(Thread* self, IndirectRef ref) {