RFR 8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion

Paul Sandoz paul.sandoz at oracle.com
Wed May 18 11:24:11 UTC 2016


Hi,

Please review:

  http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8157152-vh-array-views-atomic-add-endianness/webrev/ <http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8157152-vh-array-views-atomic-add-endianness/webrev/>

The implementation for the atomic add methods for array and byte buffer views were incorrect when the native endianness differs from the requested endianness (an embarrassing oversight).

The tests did not catch this due to values used for addition, since there was no carrying over of bits from a byte to it's subsequent higher-order byte.

If there is a mismatch in endianness then a weak+volatile CAS loop is used.

Credit goes to Frank (Yaun) for finding this and verifying.

Paul.



More information about the core-libs-dev mailing list