On Sun, 19 Dec 2021 07:05:31 GMT, liach <d...@openjdk.java.net> wrote:

>> src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java line 
>> 695:
>> 
>>> 693: 
>>> 694:         // ensure previous fields are visible before initted is
>>> 695:         Unsafe.getUnsafe().storeStoreFence();
>> 
>> Ensuring ordering on the writer side, without also ensuring ordering on the 
>> reader side, doesn't solve an ordering problem. Just make `initted` volatile 
>> and this should be safe from a Java Memory Model perspective.
>
> On a side note, would a store load fence (like `VarHandle.storeFence`) after 
> the write be a valid alternative, so the field itself can be get plain?

I don't see such a "fence" in the VarHandle API. ?? The 
`VarHandle.storeStoreFence()` is no different in memory ordering properties to 
the `Unsafe.storeStoreFence()`.

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

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

Reply via email to