RFR: 8314480: Memory ordering spec updates in java.lang.ref [v31]

Hans Boehm hboehm at google.com
Fri May 10 17:54:40 UTC 2024


I'm not convinced this helps.

The isAlive() spec says:

"A thread is alive if it has been started and has not yet terminated."

Clearly an object is reachable if it can be accessed by a thread that will
be started in the future. Is that part of a "potential continuing
computation from any live thread"?

I think the JLS wording is a bit sloppy about what "live thread" means
here. And that sloppiness is probably better than pointing at a precise
definition that I'm not sure really applies. "in any potential continuing
computation from any live thread" really seems to mean something like "in
any continuing computation in which no finalizers are run"?

Even if the object is later accessed from an existing "live" thread, it
should not be considered reachable if that happens only after a finalizer
later makes it reachable again. So I don't see why the thread from which
the access happens matters at all.

Hans

On Thu, May 9, 2024 at 11:44 AM Brent Christian <bchristi at openjdk.org>
wrote:

> > Classes in the `java.lang.ref` package would benefit from an update to
> bring the spec in line with how the VM already behaves. The changes would
> focus on _happens-before_ edges at some key points during reference
> processing.
> >
> > A couple key things we want to be able to say are:
> > - `Reference.reachabilityFence(x)` _happens-before_ reference processing
> occurs for 'x'.
> > - `Cleaner.register()` _happens-before_ the Cleaner thread runs the
> registered cleaning action.
> >
> > This will bring Cleaner in line (or close) with the memory visibility
> guarantees made for finalizers in [JLS 17.4.5](
> https://docs.oracle.com/javase/specs/jls/se18/html/jls-17.html#jls-17.4.5
> ):
> > _"There is a happens-before edge from the end of a constructor of an
> object to the start of a finalizer (§12.6) for that object."_
>
> Brent Christian has updated the pull request incrementally with one
> additional commit since the last revision:
>
>   add link to Thread.isAlive()
>
> -------------
>
> Changes:
>   - all: https://git.openjdk.org/jdk/pull/16644/files
>   - new: https://git.openjdk.org/jdk/pull/16644/files/5db47889..4efa5d18
>
> Webrevs:
>  - full: https://webrevs.openjdk.org/?repo=jdk&pr=16644&range=30
>  - incr: https://webrevs.openjdk.org/?repo=jdk&pr=16644&range=29-30
>
>   Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
>   Patch: https://git.openjdk.org/jdk/pull/16644.diff
>   Fetch: git fetch https://git.openjdk.org/jdk.git
> pull/16644/head:pull/16644
>
> PR: https://git.openjdk.org/jdk/pull/16644
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20240510/59fbaa88/attachment.htm>


More information about the core-libs-dev mailing list