More consistently use refersTo()

... to avoid accidentally keeping referents live by dereferencing
WeakReferences, e.g. as part of a null check.

This represents a quick pass over libcore.

I chose not to change WeakHashMap, which initially appeared to me to
be an obvious candidate. But it appears that replacing the initial ==
check in eq() there would only eliminate the get() call in the easy case
in which we already have the key, and thus can't possibly extend
its lifetime.

Test: Build and boot AOSP.
Bug: 215259836
Change-Id: I21dee054f3ea0cde7db3e42f738253324dcfaf68
3 files changed