< prev index next >

src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template

Print this page
rev 52786 : 8210031: implementation for JVM Constants API


  50     @ForceInline
  51     static $type$ convEndian(boolean big, $rawType$ rv) {
  52         rv = big == BE ? rv : $RawBoxType$.reverseBytes(rv);
  53         return $Type$.$rawType$BitsTo$Type$(rv);
  54     }
  55 #else[floatingPoint]
  56     @ForceInline
  57     static $type$ convEndian(boolean big, $type$ n) {
  58         return big == BE ? n : $BoxType$.reverseBytes(n);
  59     }
  60 #end[floatingPoint]
  61 
  62 
  63     private static abstract class ByteArrayViewVarHandle extends VarHandle {
  64         final boolean be;
  65 
  66         ByteArrayViewVarHandle(VarForm form, boolean be) {
  67             super(form);
  68             this.be = be;
  69         }











  70     }
  71 
  72     static final class ArrayHandle extends ByteArrayViewVarHandle {
  73 
  74         ArrayHandle(boolean be) {
  75             super(ArrayHandle.FORM, be);
  76         }
  77 
  78         @Override
  79         final MethodType accessModeTypeUncached(AccessMode accessMode) {
  80             return accessMode.at.accessModeType(byte[].class, $type$.class, int.class);
  81         }
  82 
  83         @ForceInline
  84         static int index(byte[] ba, int index) {
  85             return Preconditions.checkIndex(index, ba.length - ALIGN, null);
  86         }
  87 
  88         @ForceInline
  89         static long address(byte[] ba, int index) {




  50     @ForceInline
  51     static $type$ convEndian(boolean big, $rawType$ rv) {
  52         rv = big == BE ? rv : $RawBoxType$.reverseBytes(rv);
  53         return $Type$.$rawType$BitsTo$Type$(rv);
  54     }
  55 #else[floatingPoint]
  56     @ForceInline
  57     static $type$ convEndian(boolean big, $type$ n) {
  58         return big == BE ? n : $BoxType$.reverseBytes(n);
  59     }
  60 #end[floatingPoint]
  61 
  62 
  63     private static abstract class ByteArrayViewVarHandle extends VarHandle {
  64         final boolean be;
  65 
  66         ByteArrayViewVarHandle(VarForm form, boolean be) {
  67             super(form);
  68             this.be = be;
  69         }
  70 
  71         @Override
  72         final boolean internalEquals(VarHandle vh) {
  73             ByteArrayViewVarHandle that = (ByteArrayViewVarHandle) vh;
  74             return be == that.be;
  75         }
  76 
  77         @Override
  78         final int internalHashCode() {
  79             return Boolean.hashCode(be);
  80         }
  81     }
  82 
  83     static final class ArrayHandle extends ByteArrayViewVarHandle {
  84 
  85         ArrayHandle(boolean be) {
  86             super(ArrayHandle.FORM, be);
  87         }
  88 
  89         @Override
  90         final MethodType accessModeTypeUncached(AccessMode accessMode) {
  91             return accessMode.at.accessModeType(byte[].class, $type$.class, int.class);
  92         }
  93 
  94         @ForceInline
  95         static int index(byte[] ba, int index) {
  96             return Preconditions.checkIndex(index, ba.length - ALIGN, null);
  97         }
  98 
  99         @ForceInline
 100         static long address(byte[] ba, int index) {


< prev index next >