[External] : Re: Finalization "interaction with memory model" (12.6.2)

Alex Buckley alex.buckley at oracle.com
Tue May 3 06:04:45 UTC 2022


On 5/2/2022 10:00 PM, Hans Boehm wrote:
> On Mon, May 2, 2022 at 5:05 PM Alex Buckley <alex.buckley at oracle.com 
> <mailto:alex.buckley at oracle.com>> wrote:
> 
>     The proposal below is an improvement because of its "might overwrite"
>     narration, but the treatment of (the non-existent) w2 is still
>     confusing. If I was spending time on it, I would try very hard to find
>     an hb(...) clause that is true rather than false. However, 12.6.2 is
>     slated for removal when finalization is removed, so it's not a priority.
> 
> I'm very surprised by that last statement. This section is phrased
> in terms of finalization since, AFAIK, the JLS doesn't talk about
> References. But the problem it addresses is not at all specific to
> finalization; it's basically the same for PhantomReferences and thus
> Cleaners.
> 
> As far as I can tell, there are basically two options here, with or without
> finalization:
> 
> 1) Keep some version of this text, or
> 2) Provide reachability guarantees only through reachabilityFence(),
> allowing references to be cleared immediately for code that doesn't
> use reachabilityFence(), and thus clearly breaking all code that uses
> References or Cleaners without reachabilityFence.
> 
> I actually think (2) is a lot cleaner, and I personally wouldn't
> object to it, but it seems like a rather dramatic change that's not
> really tied to finalizers. And to be honest, I wouldn't have expected
> it to fly.

It may be that removing finalization will require more resources to look 
at JLS 12.6 and figure out if it has JMM rules which need to be kept in 
some fashion. However, removing finalization isn't on the cards for 19, 
so it's not an immediate priority.

Alex


More information about the jdk-dev mailing list