Allow null self only in DecodeWeakGlobalDuringShutdown().
To follow up CL 169855, allow a null current thread only in
DecodeWeakGlobalDuringShutdown() as a special case rather than
DecodeWeakGlobal(). This is to prevent a bug where null is accidentally
passed to DecodeWeakGlobal().
Bug: 23897251
Change-Id: I5e7bb78ec739b8bfcf77284ed321d507737ee33e
diff --git a/runtime/java_vm_ext.h b/runtime/java_vm_ext.h
index 87430c8..b539bbd 100644
--- a/runtime/java_vm_ext.h
+++ b/runtime/java_vm_ext.h
@@ -138,6 +138,12 @@
SHARED_REQUIRES(Locks::mutator_lock_)
REQUIRES(weak_globals_lock_);
+ // Like DecodeWeakGlobal() but to be used only during a runtime shutdown where self may be
+ // null.
+ mirror::Object* DecodeWeakGlobalDuringShutdown(Thread* self, IndirectRef ref)
+ SHARED_REQUIRES(Locks::mutator_lock_)
+ REQUIRES(!weak_globals_lock_);
+
Mutex& WeakGlobalsLock() RETURN_CAPABILITY(weak_globals_lock_) {
return weak_globals_lock_;
}