On Fri, 31 Jul 2026 06:57:56 GMT, Per Minborg <[email protected]> wrote:

>> This PR proposes to improve the handling of the fields in 
>> `LazyCollections.Mutexes` so that it becomes more evident that there are no 
>> races. It is also proposed to add a defensive check of `mutexes` so that it 
>> is obvious to a reader that the `Unsafe` operation does not operate on 
>> `null`.  Furthermore, it is proposed to remove the extra `AtomicInteger` 
>> object and use an `int` field directly.
>> 
>> Please note that there is no (known) error in how the class `Mutexes` works. 
>> This PR only makes it more explicit and efficient. So, for example, we do 
>> not have to backport this PR.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Per Minborg has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains six additional 
> commits since the last revision:
> 
>  - Clarify rational for  memory semantics
>  - Merge branch 'master' into bug-race-in-mutexes
>  - Fix comment
>  - Improve comments
>  - Add comments and add explicit semantics
>  - Rework how Mutexes works

src/java.base/share/classes/java/util/LazyCollections.java line 611:

> 609:             if (mutex != null) {
> 610:                 return mutex;
> 611:             }

What if `mutex == TOMB_STONE`? (Or if that can never occur, might make sense to 
document and/or assert that it never is)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32070#discussion_r3703100932

Reply via email to