RFR: 8314480: Memory ordering spec updates in java.lang.ref [v13]
Y. Srinivas Ramakrishna
ysr at openjdk.org
Tue Mar 19 16:25:25 UTC 2024
On Tue, 19 Mar 2024 02:53:37 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/ref/package-info.java line 137:
>>
>>> 135: *
>>> 136: * A <em>reachable</em> object is any object that can be accessed in any potential
>>> 137: * continuing computation from any live thread (as stated in {@jls 12.6.1}).
>>
>> This seems like somewhat loose and sloppy wording to me. "Any potential continuing computation"? "Any live thread"? Could you share a pointer to JLS 12.6.1 being referenced here?
>
> https://docs.oracle.com/javase/specs/jls/se21/html/jls-12.html#jls-12.6.1
>
>> A reachable object is any object that can be accessed in any potential continuing computation from any live thread.
>
> It may be "loose" because the devil is in the details when it comes to reachability, but I disagree that it is "sloppy". This expresses reachability in simple terms, as a "first-order" or "Newtonian" model. There are of course "Quantum" effects that need to be dealt with in practice. The JLS alludes to this with:
>> Optimizing transformations of a program can be designed that reduce the number of objects that are reachable to be less than those which would naively be considered reachable.
Sorry, my use of words was sloppy here. I think I did mean loose or somewhat informal and therefore slippery.
What I was saying is that using terms such as "any continuing computation" doesn't make sense because this is referring to a current state of the computation. I'm not sure what "any continuing computation" from a state is because the concept of what constitutes the notion of "a continuing computation" has not been defined before. To me it sounds like a computation tree with nodes as state and transitions as edges and a continuing computation as a path through that tree into the future. The way it is written then, it sounds to the naive reader, or to me at least, as if the object is perpetually reachable by every thread always. I assume I am misinterpreting the intention of the writing, but it sounds too loose for a definition being invoked here in the javadoc. May be it can be tightened up a bit.
Could one state instead that "An object is reachable at a given state when some thread is able to access the object through a sequence of steps starting at that state without other threads taking any steps." ? Or something along those lines? Or at least something tighter than the current wording that is somewhat too loose.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16644#discussion_r1530705355
More information about the core-libs-dev
mailing list