Class ByteArraySupport

java.lang.Object
com.oracle.truffle.api.memory.ByteArraySupport

public abstract class ByteArraySupport extends Object
Utility methods to write to and read from arrays of bytes. Singletons of this class are obtained from littleEndian() or bigEndian() respectively to access byte arrays in little-endian or big-endian order.

Thread safety

The methods of this class are not safe for use by multiple concurrent threads, unless otherwise stated. If a byte array is to be used by more than one thread then access to the byte array should be controlled by appropriate synchronization.

Alignment

Unaligned accesses are allowed, but will not constant-fold during partial evaluation. If constant folding is desired, consider using the unaligned methods (e.g., getIntUnaligned(byte[], int)) to read immutable data from unaligned offsets.

Since:
20.3
  • Method Summary

    Modifier and Type
    Method
    Description
    Enables accessing multibyte Java primitives from byte arrays in big-endian order.
    abstract byte
    compareAndExchangeByte(byte[] buffer, long byteOffset, byte expected, byte x)
    Atomically exchanges the given byte with the current byte at the given byte offset from the start of the buffer, if and only if the current byte equals the expected byte.
    abstract int
    compareAndExchangeInt(byte[] buffer, long byteOffset, int expected, int x)
    Atomically exchanges the given int with the current int at the given byte offset from the start of the buffer, if and only if the current int equals the expected int.
    abstract long
    compareAndExchangeLong(byte[] buffer, long byteOffset, long expected, long x)
    Atomically exchanges the given long with the current long at the given byte offset from the start of the buffer, if and only if the current long equals the expected long.
    abstract short
    compareAndExchangeShort(byte[] buffer, long byteOffset, short expected, short x)
    Atomically exchanges the given short with the current short at the given byte offset from the start of the buffer, if and only if the current short equals the expected short.
    abstract byte
    getAndAddByte(byte[] buffer, long byteOffset, byte delta)
    Atomically adds the given byte to the current byte at the given byte offset from the start of the buffer.
    abstract int
    getAndAddInt(byte[] buffer, long byteOffset, int delta)
    Atomically adds the given int to the current int at the given byte offset from the start of the buffer.
    abstract long
    getAndAddLong(byte[] buffer, long byteOffset, long delta)
    Atomically adds the given long to the current long at the given byte offset from the start of the buffer.
    abstract short
    getAndAddShort(byte[] buffer, long byteOffset, short delta)
    Atomically adds the given short to the current short at the given byte offset from the start of the buffer.
    abstract byte
    getAndBitwiseAndByte(byte[] buffer, long byteOffset, byte mask)
    Atomically bitwise-ANDs the given byte to the current byte at the given byte offset from the start of the buffer.
    abstract int
    getAndBitwiseAndInt(byte[] buffer, long byteOffset, int mask)
    Atomically bitwise-ANDs the given int to the current int at the given byte offset from the start of the buffer.
    abstract long
    getAndBitwiseAndLong(byte[] buffer, long byteOffset, long mask)
    Atomically bitwise-ANDs the given long to the current long at the given byte offset from the start of the buffer.
    abstract short
    getAndBitwiseAndShort(byte[] buffer, long byteOffset, short mask)
    Atomically bitwise-ANDs the given short to the current short at the given byte offset from the start of the buffer.
    abstract byte
    getAndBitwiseOrByte(byte[] buffer, long byteOffset, byte mask)
    Atomically bitwise-ORs the given byte to the current byte at the given byte offset from the start of the buffer.
    abstract int
    getAndBitwiseOrInt(byte[] buffer, long byteOffset, int mask)
    Atomically bitwise-ORs the given int to the current int at the given byte offset from the start of the buffer.
    abstract long
    getAndBitwiseOrLong(byte[] buffer, long byteOffset, long mask)
    Atomically bitwise-ORs the given long to the current long at the given byte offset from the start of the buffer.
    abstract short
    getAndBitwiseOrShort(byte[] buffer, long byteOffset, short mask)
    Atomically bitwise-ORs the given short to the current short at the given byte offset from the start of the buffer.
    abstract byte
    getAndBitwiseXorByte(byte[] buffer, long byteOffset, byte mask)
    Atomically bitwise-XORs the given byte to the current byte at the given byte offset from the start of the buffer.
    abstract int
    getAndBitwiseXorInt(byte[] buffer, long byteOffset, int mask)
    Atomically bitwise-XORs the given int to the current int at the given byte offset from the start of the buffer.
    abstract long
    getAndBitwiseXorLong(byte[] buffer, long byteOffset, long mask)
    Atomically bitwise-XORs the given long to the current long at the given byte offset from the start of the buffer.
    abstract short
    getAndBitwiseXorShort(byte[] buffer, long byteOffset, short mask)
    Atomically bitwise-XORs the given short to the current short at the given byte offset from the start of the buffer.
    abstract byte
    getAndSetByte(byte[] buffer, long byteOffset, byte newValue)
    Atomically exchanges the given byte with the current byte at the given byte offset from the start of the buffer.
    abstract int
    getAndSetInt(byte[] buffer, long byteOffset, int newValue)
    Atomically exchanges the given int with the current int at the given byte offset from the start of the buffer.
    abstract long
    getAndSetLong(byte[] buffer, long byteOffset, long newValue)
    Atomically exchanges the given long with the current long at the given byte offset from the start of the buffer.
    abstract short
    getAndSetShort(byte[] buffer, long byteOffset, short newValue)
    Atomically exchanges the given short with the current short at the given byte offset from the start of the buffer.
    abstract byte
    getByte(byte[] buffer, int byteOffset)
    Reads the byte at the given byte offset from the start of the buffer.
    abstract byte
    getByte(byte[] buffer, long byteOffset)
    Reads the byte at the given byte offset from the start of the buffer.
    abstract byte
    getByteVolatile(byte[] buffer, long byteOffset)
    Volatile version of getByte(byte[], long).
    abstract double
    getDouble(byte[] buffer, int byteOffset)
    Reads the double at the given byte offset from the start of the buffer.
    abstract double
    getDouble(byte[] buffer, long byteOffset)
    Reads the double at the given byte offset from the start of the buffer.
    abstract float
    getFloat(byte[] buffer, int byteOffset)
    Reads the float at the given byte offset from the start of the buffer.
    abstract float
    getFloat(byte[] buffer, long byteOffset)
    Reads the float at the given byte offset from the start of the buffer.
    abstract int
    getInt(byte[] buffer, int byteOffset)
    Reads the int at the given byte offset from the start of the buffer.
    abstract int
    getInt(byte[] buffer, long byteOffset)
    Reads the int at the given byte offset from the start of the buffer.
    abstract int
    getIntUnaligned(byte[] buffer, int byteOffset)
    Reads the int at the given byte offset from the start of the buffer.
    abstract int
    getIntUnaligned(byte[] buffer, long byteOffset)
    Reads the int at the given byte offset from the start of the buffer.
    abstract int
    getIntVolatile(byte[] buffer, long byteOffset)
    Volatile version of getInt(byte[], long).
    abstract long
    getLong(byte[] buffer, int byteOffset)
    Reads the long at the given byte offset from the start of the buffer.
    abstract long
    getLong(byte[] buffer, long byteOffset)
    Reads the long at the given byte offset from the start of the buffer.
    abstract long
    getLongUnaligned(byte[] buffer, int byteOffset)
    Reads the long at the given byte offset from the start of the buffer.
    abstract long
    getLongUnaligned(byte[] buffer, long byteOffset)
    Reads the long at the given byte offset from the start of the buffer.
    abstract long
    getLongVolatile(byte[] buffer, long byteOffset)
    Volatile version of getLong(byte[], long).
    abstract short
    getShort(byte[] buffer, int byteOffset)
    Reads the short at the given byte offset from the start of the buffer.
    abstract short
    getShort(byte[] buffer, long byteOffset)
    Reads the short at the given byte offset from the start of the buffer.
    abstract short
    getShortUnaligned(byte[] buffer, int byteOffset)
    Reads the short at the given byte offset from the start of the buffer.
    abstract short
    getShortUnaligned(byte[] buffer, long byteOffset)
    Reads the short at the given byte offset from the start of the buffer.
    abstract short
    getShortVolatile(byte[] buffer, long byteOffset)
    Volatile version of getShort(byte[], long).
    final boolean
    inBounds(byte[] buffer, int startByteOffset, int length)
    Checks if an access is in bounds of the given buffer.
    final boolean
    inBounds(byte[] buffer, long startByteOffset, long length)
    Checks if an access is in bounds of the given buffer.
    Enables accessing multibyte Java primitives from byte arrays in little-endian order.
    abstract void
    putByte(byte[] buffer, int byteOffset, byte value)
    Writes the given byte at the given byte offset from the start of the buffer.
    abstract void
    putByte(byte[] buffer, long byteOffset, byte value)
    Writes the given byte at the given byte offset from the start of the buffer.
    abstract void
    putByteVolatile(byte[] buffer, long byteOffset, byte value)
    Volatile version of putByte(byte[], long, byte).
    abstract void
    putDouble(byte[] buffer, int byteOffset, double value)
    Writes the given double at the given byte offset from the start of the buffer.
    abstract void
    putDouble(byte[] buffer, long byteOffset, double value)
    Writes the given double at the given byte offset from the start of the buffer.
    abstract void
    putFloat(byte[] buffer, int byteOffset, float value)
    Writes the given float at the given byte offset from the start of the buffer.
    abstract void
    putFloat(byte[] buffer, long byteOffset, float value)
    Writes the given float at the given byte offset from the start of the buffer.
    abstract void
    putInt(byte[] buffer, int byteOffset, int value)
    Writes the given int at the given byte offset from the start of the buffer.
    abstract void
    putInt(byte[] buffer, long byteOffset, int value)
    Writes the given int at the given byte offset from the start of the buffer.
    abstract void
    putIntVolatile(byte[] buffer, long byteOffset, int value)
    Volatile version of putInt(byte[], long, int).
    abstract void
    putLong(byte[] buffer, int byteOffset, long value)
    Writes the given long at the given byte offset from the start of the buffer.
    abstract void
    putLong(byte[] buffer, long byteOffset, long value)
    Writes the given long at the given byte offset from the start of the buffer.
    abstract void
    putLongVolatile(byte[] buffer, long byteOffset, long value)
    Volatile version of putLong(byte[], long, long).
    abstract void
    putShort(byte[] buffer, int byteOffset, short value)
    Writes the given short at the given byte offset from the start of the buffer.
    abstract void
    putShort(byte[] buffer, long byteOffset, short value)
    Writes the given short at the given byte offset from the start of the buffer.
    abstract void
    putShortVolatile(byte[] buffer, long byteOffset, short value)
    Volatile version of putShort(byte[], long, short).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • littleEndian

      public static ByteArraySupport littleEndian()
      Enables accessing multibyte Java primitives from byte arrays in little-endian order.

      Example usage:

       byte[] buffer = new byte[]{0, 0, 0, 0};
       ByteArraySupport.littleEndian().putShort(buffer, 2, (short) 1);
       // buffer[2] == (byte) 1
       // buffer[3] == (byte) 0
       ByteArraySupport.littleEndian().putShort(buffer, 3, (short) 1);
       // throws IndexOutOfBoundsException exception
       
      Since:
      20.3
    • bigEndian

      public static ByteArraySupport bigEndian()
      Enables accessing multibyte Java primitives from byte arrays in big-endian order.

      Example usage:

       byte[] buffer = new byte[]{0, 0, 0, 0};
       ByteArraySupport.bigEndian().putShort(buffer, 0, (short) 1);
       // buffer[0] == (byte) 0
       // buffer[1] == (byte) 1
       
      Since:
      20.3
    • inBounds

      public final boolean inBounds(byte[] buffer, int startByteOffset, int length)
      Checks if an access is in bounds of the given buffer.

      If out-of-bounds accesses are expected to happen frequently, it is faster (~1.2x in interpreter mode) to use this method to check for them than catching IndexOutOfBoundsExceptions.

      Parameters:
      buffer - the byte array
      startByteOffset - the start byte offset of the access
      length - the number of bytes accessed
      Returns:
      True if the access is in bounds, false otherwise
      Since:
      20.3
    • inBounds

      public final boolean inBounds(byte[] buffer, long startByteOffset, long length)
      Checks if an access is in bounds of the given buffer.

      If out-of-bounds accesses are expected to happen frequently, it is faster (~1.2x in interpreter mode) to use this method to check for them than catching IndexOutOfBoundsExceptions.

      Parameters:
      buffer - the byte array
      startByteOffset - the start byte offset of the access
      length - the number of bytes accessed
      Returns:
      True if the access is in bounds, false otherwise
      Since:
      22.2
    • getByte

      public abstract byte getByte(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException
      Reads the byte at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the byte will be read
      Returns:
      the byte at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      20.3
    • getByte

      public abstract byte getByte(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Reads the byte at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the byte will be read
      Returns:
      the byte at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      22.2
    • putByte

      public abstract void putByte(byte[] buffer, int byteOffset, byte value) throws IndexOutOfBoundsException
      Writes the given byte at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset at which the byte will be written
      value - the byte value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      20.3
    • putByte

      public abstract void putByte(byte[] buffer, long byteOffset, byte value) throws IndexOutOfBoundsException
      Writes the given byte at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset at which the byte will be written
      value - the byte value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      22.2
    • getShort

      public abstract short getShort(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException
      Reads the short at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the short will be read
      Returns:
      the short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      20.3
    • getShort

      public abstract short getShort(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Reads the short at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the short will be read
      Returns:
      the short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      22.2
    • putShort

      public abstract void putShort(byte[] buffer, int byteOffset, short value) throws IndexOutOfBoundsException
      Writes the given short at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the short will be written
      value - the short value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      20.3
    • putShort

      public abstract void putShort(byte[] buffer, long byteOffset, short value) throws IndexOutOfBoundsException
      Writes the given short at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the short will be written
      value - the short value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      22.2
    • getInt

      public abstract int getInt(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException
      Reads the int at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the int will be read
      Returns:
      the int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      20.3
    • getInt

      public abstract int getInt(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Reads the int at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the int will be read
      Returns:
      the int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      20.3
    • putInt

      public abstract void putInt(byte[] buffer, int byteOffset, int value) throws IndexOutOfBoundsException
      Writes the given int at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the int will be written
      value - the int value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      20.3
    • putInt

      public abstract void putInt(byte[] buffer, long byteOffset, int value) throws IndexOutOfBoundsException
      Writes the given int at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the int will be written
      value - the int value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      22.2
    • getLong

      public abstract long getLong(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException
      Reads the long at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the int will be read
      Returns:
      the int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      20.3
    • getLong

      public abstract long getLong(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Reads the long at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the int will be read
      Returns:
      the int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      22.2
    • putLong

      public abstract void putLong(byte[] buffer, int byteOffset, long value) throws IndexOutOfBoundsException
      Writes the given long at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the int will be written
      value - the int value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      20.3
    • putLong

      public abstract void putLong(byte[] buffer, long byteOffset, long value) throws IndexOutOfBoundsException
      Writes the given long at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the int will be written
      value - the int value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      22.2
    • getFloat

      public abstract float getFloat(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException
      Reads the float at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the float will be read
      Returns:
      the float at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      20.3
    • getFloat

      public abstract float getFloat(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Reads the float at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the float will be read
      Returns:
      the float at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      22.2
    • putFloat

      public abstract void putFloat(byte[] buffer, int byteOffset, float value) throws IndexOutOfBoundsException
      Writes the given float at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the float will be written
      value - the float value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      20.3
    • putFloat

      public abstract void putFloat(byte[] buffer, long byteOffset, float value) throws IndexOutOfBoundsException
      Writes the given float at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the float will be written
      value - the float value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      22.2
    • getDouble

      public abstract double getDouble(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException
      Reads the double at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the double will be read
      Returns:
      the double at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      20.3
    • getDouble

      public abstract double getDouble(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Reads the double at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the double will be read
      Returns:
      the double at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      22.2
    • putDouble

      public abstract void putDouble(byte[] buffer, int byteOffset, double value) throws IndexOutOfBoundsException
      Writes the given double at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the double will be written
      value - the double value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      20.3
    • putDouble

      public abstract void putDouble(byte[] buffer, long byteOffset, double value) throws IndexOutOfBoundsException
      Writes the given double at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to write in
      byteOffset - the byte offset from which the double will be written
      value - the double value to be written
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      22.2
    • getShortUnaligned

      public abstract short getShortUnaligned(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException
      Reads the short at the given byte offset from the start of the buffer. Unlike getShort(byte[], int), the byte offset does not need to be short-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the short will be read
      Returns:
      the short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      24.2
    • getShortUnaligned

      public abstract short getShortUnaligned(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Reads the short at the given byte offset from the start of the buffer. Unlike getShort(byte[], long), the byte offset does not need to be short-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the short will be read
      Returns:
      the short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      24.2
    • getIntUnaligned

      public abstract int getIntUnaligned(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException
      Reads the int at the given byte offset from the start of the buffer. Unlike getInt(byte[], int), the byte offset does not need to be int-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the int will be read
      Returns:
      the int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      24.2
    • getIntUnaligned

      public abstract int getIntUnaligned(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Reads the int at the given byte offset from the start of the buffer. Unlike getInt(byte[], long), the byte offset does not need to be int-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the int will be read
      Returns:
      the int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      24.2
    • getLongUnaligned

      public abstract long getLongUnaligned(byte[] buffer, int byteOffset) throws IndexOutOfBoundsException
      Reads the long at the given byte offset from the start of the buffer. Unlike getLong(byte[], int), the byte offset does not need to be long-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the long will be read
      Returns:
      the long at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      24.2
    • getLongUnaligned

      public abstract long getLongUnaligned(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Reads the long at the given byte offset from the start of the buffer. Unlike getLong(byte[], long), the byte offset does not need to be long-aligned. The platform may not support atomic unaligned reads, so this method should not be used with shared mutable data.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset from which the long will be read
      Returns:
      the long at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      24.2
    • getByteVolatile

      public abstract byte getByteVolatile(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Volatile version of getByte(byte[], long).
      Throws:
      IndexOutOfBoundsException
      Since:
      23.1
    • putByteVolatile

      public abstract void putByteVolatile(byte[] buffer, long byteOffset, byte value) throws IndexOutOfBoundsException
      Volatile version of putByte(byte[], long, byte).
      Throws:
      IndexOutOfBoundsException
      Since:
      23.1
    • getShortVolatile

      public abstract short getShortVolatile(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Volatile version of getShort(byte[], long).
      Throws:
      IndexOutOfBoundsException
      Since:
      23.1
    • putShortVolatile

      public abstract void putShortVolatile(byte[] buffer, long byteOffset, short value) throws IndexOutOfBoundsException
      Volatile version of putShort(byte[], long, short).
      Throws:
      IndexOutOfBoundsException
      Since:
      23.1
    • getIntVolatile

      public abstract int getIntVolatile(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Volatile version of getInt(byte[], long).
      Throws:
      IndexOutOfBoundsException
      Since:
      23.1
    • putIntVolatile

      public abstract void putIntVolatile(byte[] buffer, long byteOffset, int value) throws IndexOutOfBoundsException
      Volatile version of putInt(byte[], long, int).
      Throws:
      IndexOutOfBoundsException
      Since:
      23.1
    • getLongVolatile

      public abstract long getLongVolatile(byte[] buffer, long byteOffset) throws IndexOutOfBoundsException
      Volatile version of getLong(byte[], long).
      Throws:
      IndexOutOfBoundsException
      Since:
      23.1
    • putLongVolatile

      public abstract void putLongVolatile(byte[] buffer, long byteOffset, long value) throws IndexOutOfBoundsException
      Volatile version of putLong(byte[], long, long).
      Throws:
      IndexOutOfBoundsException
      Since:
      23.1
    • getAndAddByte

      public abstract byte getAndAddByte(byte[] buffer, long byteOffset, byte delta) throws IndexOutOfBoundsException
      Atomically adds the given byte to the current byte at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the byte will be read and written to
      delta - the byte value to add
      Returns:
      the previous byte at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      23.1
    • getAndAddShort

      public abstract short getAndAddShort(byte[] buffer, long byteOffset, short delta) throws IndexOutOfBoundsException
      Atomically adds the given short to the current short at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the short will be read and written to
      delta - the short value to add
      Returns:
      the previous short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      23.1
    • getAndAddInt

      public abstract int getAndAddInt(byte[] buffer, long byteOffset, int delta) throws IndexOutOfBoundsException
      Atomically adds the given int to the current int at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the int will be read and written to
      delta - the int value to add
      Returns:
      the previous int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      23.1
    • getAndAddLong

      public abstract long getAndAddLong(byte[] buffer, long byteOffset, long delta) throws IndexOutOfBoundsException
      Atomically adds the given long to the current long at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the long will be read and written to
      delta - the long value to add
      Returns:
      the previous long at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      23.1
    • getAndBitwiseAndByte

      public abstract byte getAndBitwiseAndByte(byte[] buffer, long byteOffset, byte mask) throws IndexOutOfBoundsException
      Atomically bitwise-ANDs the given byte to the current byte at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the byte will be read and written to
      mask - the byte value to bitwise-AND
      Returns:
      the previous byte at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      23.1
    • getAndBitwiseAndShort

      public abstract short getAndBitwiseAndShort(byte[] buffer, long byteOffset, short mask) throws IndexOutOfBoundsException
      Atomically bitwise-ANDs the given short to the current short at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the short will be read and written to
      mask - the short value to bitwise-AND
      Returns:
      the previous short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      23.1
    • getAndBitwiseAndInt

      public abstract int getAndBitwiseAndInt(byte[] buffer, long byteOffset, int mask) throws IndexOutOfBoundsException
      Atomically bitwise-ANDs the given int to the current int at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the int will be read and written to
      mask - the int value to bitwise-AND
      Returns:
      the previous int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      23.1
    • getAndBitwiseAndLong

      public abstract long getAndBitwiseAndLong(byte[] buffer, long byteOffset, long mask) throws IndexOutOfBoundsException
      Atomically bitwise-ANDs the given long to the current long at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the long will be read and written to
      mask - the long value to bitwise-AND
      Returns:
      the previous long at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      23.1
    • getAndBitwiseOrByte

      public abstract byte getAndBitwiseOrByte(byte[] buffer, long byteOffset, byte mask) throws IndexOutOfBoundsException
      Atomically bitwise-ORs the given byte to the current byte at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the byte will be read and written to
      mask - the byte value to bitwise-OR
      Returns:
      the previous byte at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      23.1
    • getAndBitwiseOrShort

      public abstract short getAndBitwiseOrShort(byte[] buffer, long byteOffset, short mask) throws IndexOutOfBoundsException
      Atomically bitwise-ORs the given short to the current short at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the short will be read and written to
      mask - the short value to bitwise-OR
      Returns:
      the previous short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      23.1
    • getAndBitwiseOrInt

      public abstract int getAndBitwiseOrInt(byte[] buffer, long byteOffset, int mask) throws IndexOutOfBoundsException
      Atomically bitwise-ORs the given int to the current int at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the int will be read and written to
      mask - the int value to bitwise-OR
      Returns:
      the previous int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      23.1
    • getAndBitwiseOrLong

      public abstract long getAndBitwiseOrLong(byte[] buffer, long byteOffset, long mask) throws IndexOutOfBoundsException
      Atomically bitwise-ORs the given long to the current long at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the long will be read and written to
      mask - the long value to bitwise-OR
      Returns:
      the previous long at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      23.1
    • getAndBitwiseXorByte

      public abstract byte getAndBitwiseXorByte(byte[] buffer, long byteOffset, byte mask) throws IndexOutOfBoundsException
      Atomically bitwise-XORs the given byte to the current byte at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the byte will be read and written to
      mask - the byte value to bitwise-XOR
      Returns:
      the previous byte at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      23.1
    • getAndBitwiseXorShort

      public abstract short getAndBitwiseXorShort(byte[] buffer, long byteOffset, short mask) throws IndexOutOfBoundsException
      Atomically bitwise-XORs the given short to the current short at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the short will be read and written to
      mask - the short value to bitwise-XOR
      Returns:
      the previous short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      23.1
    • getAndBitwiseXorInt

      public abstract int getAndBitwiseXorInt(byte[] buffer, long byteOffset, int mask) throws IndexOutOfBoundsException
      Atomically bitwise-XORs the given int to the current int at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the int will be read and written to
      mask - the int value to bitwise-XOR
      Returns:
      the previous int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      23.1
    • getAndBitwiseXorLong

      public abstract long getAndBitwiseXorLong(byte[] buffer, long byteOffset, long mask) throws IndexOutOfBoundsException
      Atomically bitwise-XORs the given long to the current long at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the long will be read and written to
      mask - the long value to bitwise-XOR
      Returns:
      the previous long at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      23.1
    • getAndSetByte

      public abstract byte getAndSetByte(byte[] buffer, long byteOffset, byte newValue) throws IndexOutOfBoundsException
      Atomically exchanges the given byte with the current byte at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the byte will be read and written to
      newValue - the new byte value
      Returns:
      the previous byte at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      23.1
    • getAndSetShort

      public abstract short getAndSetShort(byte[] buffer, long byteOffset, short newValue) throws IndexOutOfBoundsException
      Atomically exchanges the given short with the current short at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the short will be read and written to
      newValue - the new short value
      Returns:
      the previous short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      23.1
    • getAndSetInt

      public abstract int getAndSetInt(byte[] buffer, long byteOffset, int newValue) throws IndexOutOfBoundsException
      Atomically exchanges the given int with the current int at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the int will be read and written to
      newValue - the new int value
      Returns:
      the previous int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      23.1
    • getAndSetLong

      public abstract long getAndSetLong(byte[] buffer, long byteOffset, long newValue) throws IndexOutOfBoundsException
      Atomically exchanges the given long with the current long at the given byte offset from the start of the buffer.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the long will be read and written to
      newValue - the new long value
      Returns:
      the previous long at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      23.1
    • compareAndExchangeByte

      public abstract byte compareAndExchangeByte(byte[] buffer, long byteOffset, byte expected, byte x) throws IndexOutOfBoundsException
      Atomically exchanges the given byte with the current byte at the given byte offset from the start of the buffer, if and only if the current byte equals the expected byte.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the byte will be read and written to
      expected - the expected byte value
      x - the replacement byte value
      Returns:
      the previous byte at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length
      Since:
      23.1
    • compareAndExchangeShort

      public abstract short compareAndExchangeShort(byte[] buffer, long byteOffset, short expected, short x) throws IndexOutOfBoundsException
      Atomically exchanges the given short with the current short at the given byte offset from the start of the buffer, if and only if the current short equals the expected short.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the short will be read and written to
      expected - the expected short value
      x - the replacement short value
      Returns:
      the previous short at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 1
      Since:
      23.1
    • compareAndExchangeInt

      public abstract int compareAndExchangeInt(byte[] buffer, long byteOffset, int expected, int x) throws IndexOutOfBoundsException
      Atomically exchanges the given int with the current int at the given byte offset from the start of the buffer, if and only if the current int equals the expected int.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the int will be read and written to
      expected - the expected int value
      x - the replacement int value
      Returns:
      the previous int at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 3
      Since:
      23.1
    • compareAndExchangeLong

      public abstract long compareAndExchangeLong(byte[] buffer, long byteOffset, long expected, long x) throws IndexOutOfBoundsException
      Atomically exchanges the given long with the current long at the given byte offset from the start of the buffer, if and only if the current long equals the expected long.
      Parameters:
      buffer - the byte array to read from
      byteOffset - the byte offset at which the long will be read and written to
      expected - the expected long value
      x - the replacement long value
      Returns:
      the previous long at the given byte offset from the start of the buffer
      Throws:
      IndexOutOfBoundsException - if and only if byteOffset < 0 || byteOffset >= buffer.length - 7
      Since:
      23.1