On Mon, 7 Sep 2026 17:40:51 GMT, Jorn Vernee <[email protected]> wrote:

>> src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template
>>  line 244:
>> 
>>> 242:         try {
>>> 243:             if (session != null) {
>>> 244:                 session.acquire0();
>> 
>> Could we move `acquire0()` before the TWR-block, or otherwise ensure that 
>> `release0()` is called only after a successful acquisition? As written, if 
>> `acquire0()` fails (e.g., because of `WrongThreadException`), the 
>> bookkeeping gets wrong with unmatched accountings. 
>> 
>> Perhaps we should add a regression test for this as well?
>
> Good catch! We should indeed move the acquire outside of the try block.

I've fixed this and added a test

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31918#discussion_r3952036587

Reply via email to