当强引用直接访问弱引用时

when strong reference directly access weak reference

在Java中,当目标对象A只能被弱引用B到达时,A才可以被GC。 如果强引用 C 同时到达弱引用 B 会发生什么?例如,C 指向一个 class 实例,它包含一个指向 A 的弱引用字段 B。 如果C是活的,并且没有其他对obj A的弱引用或强引用,A还能被GC吗?

是的,因为有一个弱引用作为 link 它被认为是弱可达的。 Weak reference 上的维基百科条目说(部分)

A weak reference is a reference that does not protect the referenced object from collection by a garbage collector, unlike a strong reference. An object referenced only by weak references – meaning "every chain of references that reaches the object includes at least one weak reference as a link" – is considered weakly reachable, and can be treated as unreachable and so may be collected at any time.