RFR 9: 8138696 : java.lang.ref.Cleaner - an easy to use alternative to finalization

Andrew Haley aph at redhat.com
Wed Oct 21 15:36:08 UTC 2015

On 10/21/2015 03:52 PM, Roger Riggs wrote:
> So then is is correct to conclude that the gc does examine fields in 
> instances
> still being constructed to determine reachability?

Oh sure, it has to.  The issue here is that the object being
constructed is a weak reference, and therefore its referent is weakly
reachable.  If it were any other kind of object it'd be OK.

> How is that we have gone so long without needing reachabilityFence?

There have been objects finalized early on some systems, particularly
J9 which for some reason finalizes objects much more quickly than
HotSpot does.

> Or is it just because optimizers have taken so long to get a perfect 
> view of reference scope?

That too.


More information about the core-libs-dev mailing list