RFR: 8286669: Replace MethodHandle specialization with ASM in mainline [v3]

Rémi Forax forax at openjdk.java.net
Tue May 17 14:33:52 UTC 2022


On Tue, 17 May 2022 11:57:01 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/abi/SoftReferenceCache.java line 42:
>> 
>>> 40: 
>>> 41:     private class Node {
>>> 42:         private SoftReference<V> ref;
>> 
>> this code looks like a double check locking so ref should be volatile
>
> Thanks. I thought the `moniterenter` & `monitorexit` were enough here for visibility. I've read up on this and it looks like `volatile` is needed to correctly order the constructor and apply call (and contents) before the write to the `ref` field.

yes, otherwise another thread than the one inside the `monitorenter`/`monitorexit` that is initializing the object can see the object half initialized.

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

PR: https://git.openjdk.java.net/jdk/pull/8685


More information about the core-libs-dev mailing list