jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
changeset 38356 1e4ecca97792
parent 36934 590fc47a0aeb
child 38358 cb99c6d2af1b
equal deleted inserted replaced
38355:674cfd9b90cf 38356:1e4ecca97792
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 package java.lang.invoke;
    25 package java.lang.invoke;
    26 
    26 
    27 import jdk.internal.misc.Unsafe;
    27 import jdk.internal.misc.Unsafe;
       
    28 import jdk.internal.util.Preconditions;
    28 import jdk.internal.vm.annotation.ForceInline;
    29 import jdk.internal.vm.annotation.ForceInline;
    29 
    30 
    30 import java.nio.ByteBuffer;
    31 import java.nio.ByteBuffer;
    31 import java.nio.ReadOnlyBufferException;
    32 import java.nio.ReadOnlyBufferException;
    32 import java.util.Objects;
    33 import java.util.Objects;
    76             super(ArrayHandle.class, byte[].class, $type$.class, be);
    77             super(ArrayHandle.class, byte[].class, $type$.class, be);
    77         }
    78         }
    78 
    79 
    79         @ForceInline
    80         @ForceInline
    80         static int index(byte[] ba, int index) {
    81         static int index(byte[] ba, int index) {
    81             return Objects.checkIndex(index, ba.length - ALIGN, null);
    82             return Preconditions.checkIndex(index, ba.length - ALIGN, null);
    82         }
    83         }
    83 
    84 
    84         @ForceInline
    85         @ForceInline
    85         static long address(byte[] ba, int index) {
    86         static long address(byte[] ba, int index) {
    86             long address = ((long) index) + Unsafe.ARRAY_BYTE_BASE_OFFSET;
    87             long address = ((long) index) + Unsafe.ARRAY_BYTE_BASE_OFFSET;
   285             super(ByteBufferHandle.class, ByteBuffer.class, $type$.class, be);
   286             super(ByteBufferHandle.class, ByteBuffer.class, $type$.class, be);
   286         }
   287         }
   287 
   288 
   288         @ForceInline
   289         @ForceInline
   289         static int index(ByteBuffer bb, int index) {
   290         static int index(ByteBuffer bb, int index) {
   290             return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
   291             return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
   291         }
   292         }
   292 
   293 
   293         @ForceInline
   294         @ForceInline
   294         static int indexRO(ByteBuffer bb, int index) {
   295         static int indexRO(ByteBuffer bb, int index) {
   295             if (UNSAFE.getBoolean(bb, BYTE_BUFFER_IS_READ_ONLY))
   296             if (UNSAFE.getBoolean(bb, BYTE_BUFFER_IS_READ_ONLY))
   296                 throw new ReadOnlyBufferException();
   297                 throw new ReadOnlyBufferException();
   297             return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
   298             return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null);
   298         }
   299         }
   299 
   300 
   300         @ForceInline
   301         @ForceInline
   301         static long address(ByteBuffer bb, int index) {
   302         static long address(ByteBuffer bb, int index) {
   302             long address = ((long) index) + UNSAFE.getLong(bb, BUFFER_ADDRESS);
   303             long address = ((long) index) + UNSAFE.getLong(bb, BUFFER_ADDRESS);