Finalization "interaction with memory model" (12.6.2)

Hans Boehm hboehm at google.com
Tue May 3 05:00:51 UTC 2022


On Mon, May 2, 2022 at 5:05 PM Alex Buckley <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.

Hans


More information about the jdk-dev mailing list