Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8157152

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • core-libs
    • None

      The implementations of VarHandle.getAndAdd/addAndGet for the byte[]/ByteBuffer views are incorrect if endian conversion is performed. The atomic addition is performed on the encoded augend.

      It just so happened that the associated tests use values that do not result in overflow over the byte ranges, hence a bad result was not observed.
       
      If the native endianess does not match that on the VarHandle then the atomic add should be performed in a CAS loop.

            psandoz Paul Sandoz
            psandoz Paul Sandoz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: