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

Brent Christian bchristi at openjdk.org
Thu Feb 22 01:09:58 UTC 2024


On Wed, 21 Feb 2024 01:52:57 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Brent Christian has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Updates to reachabilityFence()
>
> src/java.base/share/classes/java/lang/ref/package-info.java line 118:
> 
>> 116:  *
>> 117:  * <li>The Cleaner thread dequeues a reference to a registered object before
>> 118:  * running the cleaning action for that object.</li>
> 
> Do you want to rephrase this so that it too mentions `happens-before`? e.g.
> 
> Dequeuing of a reference to a registered object, by the Cleaner thread, 
> happens-before the execution of the cleaning action for that object.

I hesitated to state it that way because there's not a synchronization action _per se_ between the Cleaning thread dequeuing, and then running the cleaning action.

However, I see that JLS 17.4.5 does state:
_"If x and y are actions of the same thread and x comes before y in program order, then hb(x, y)."_
(That is, x _happens-before_ y).

So yes, we can say _happens-before_ here. Thanks!

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16644#discussion_r1498493650


More information about the core-libs-dev mailing list