RFR: 8315131: Clarify VarHandle set/get access on 32-bit platforms

Chen Liang liach at openjdk.org
Fri Jul 11 13:19:38 UTC 2025


On Fri, 11 Jul 2025 13:05:09 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 4311:
>> 
>>> 4309:      *     access modes {@code get} and {@code set} for {@code long}, {@code
>>> 4310:      *     double} are supported but might lead to word tearing, as described in
>>> 4311:      *     Section {@jls 17.7} of <cite>The Java Language Specification</cite>.
>> 
>> ...except that JLS 17.7 is "Non-Atomic Treatment of double and long". Word tearing (JLS 17.6) should still be very much forbidden. This all means that [MemoryLayout.java](https://github.com/openjdk/jdk/blob/ee0d309bbd33302d8c6f35155e975db77aaea785/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java#L279-L282) comment is also incorrect.
>> 
>> Note how the previous paragraph talks about "support atomic access", which is a correct term here.
>
> Right, "word tearing" and "non-atomic access" are different notions.

True, word tearing is racing a single memory location. Good that we discovered another spec bug and could fix it in time for 25.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26258#discussion_r2200726935


More information about the core-libs-dev mailing list