< prev index next >

test/hotspot/jtreg/runtime/valhalla/valuetypes/TestValue4.java

Print this page




  39     final byte b3;
  40     final byte b4;
  41     final short s1;
  42     final short s2;
  43     final int i;
  44     final long l;
  45     final String val;
  46 
  47     private TestValue4() {
  48         i = (int)System.nanoTime();
  49         val = Integer.valueOf(i).toString();
  50         l = ((long)i) << Integer.SIZE | i;
  51         s1 = (short)(i & ~Short.MIN_VALUE);
  52         s2 = (short)(i >> Short.SIZE);
  53         b1 = (byte)(i & ~Byte.MIN_VALUE);
  54         b2 = (byte)((i >> Byte.SIZE) & ~Byte.MIN_VALUE);
  55         b3 = (byte)((i >> (2 * Byte.SIZE)) & ~Byte.MIN_VALUE);
  56         b4 = (byte)((i >> (3 * Byte.SIZE)) & ~Byte.MIN_VALUE);
  57     }
  58 
  59     __ValueFactory public static TestValue4 create(int i) {
  60         TestValue4 v = __MakeDefault TestValue4();
  61         v.i = i;
  62         v.val = Integer.valueOf(i).toString();
  63         ByteBuffer bf = ByteBuffer.allocate(8);
  64         bf.putInt(0, i);
  65         bf.putInt(4, i);
  66         v.l = bf.getLong(0);
  67         v.s1 = bf.getShort(2);
  68         v.s2 = bf.getShort(0);
  69         v.b1 = bf.get(3);
  70         v.b2 = bf.get(2);
  71         v.b3 = bf.get(1);
  72         v.b4 = bf.get(0);
  73         return v;
  74     }
  75 
  76     __ValueFactory public static TestValue4 create() {
  77         return create((int)System.nanoTime());
  78     }
  79 
  80     public static TestValue4 getInstance() {
  81         return create();
  82     }
  83 
  84     public static TestValue4 getNonBufferedInstance() {
  85         return staticValue;
  86     }
  87 
  88     public boolean verify() {
  89         if (val == null) {
  90             return i == 0 && l == 0 && b1 == 0 && b2 == 0 && b3 == 0 && b4 == 0
  91                     && s1 == 0 && s2 == 0;
  92         }
  93         ByteBuffer bf = ByteBuffer.allocate(8);
  94         bf.putInt(0, i);
  95         bf.putInt(4, i);
  96         long nl =  bf.getLong(0);


  39     final byte b3;
  40     final byte b4;
  41     final short s1;
  42     final short s2;
  43     final int i;
  44     final long l;
  45     final String val;
  46 
  47     private TestValue4() {
  48         i = (int)System.nanoTime();
  49         val = Integer.valueOf(i).toString();
  50         l = ((long)i) << Integer.SIZE | i;
  51         s1 = (short)(i & ~Short.MIN_VALUE);
  52         s2 = (short)(i >> Short.SIZE);
  53         b1 = (byte)(i & ~Byte.MIN_VALUE);
  54         b2 = (byte)((i >> Byte.SIZE) & ~Byte.MIN_VALUE);
  55         b3 = (byte)((i >> (2 * Byte.SIZE)) & ~Byte.MIN_VALUE);
  56         b4 = (byte)((i >> (3 * Byte.SIZE)) & ~Byte.MIN_VALUE);
  57     }
  58 
  59     public static TestValue4 create(int i) {
  60         TestValue4 v = __MakeDefault TestValue4();
  61         v.i = i;
  62         v.val = Integer.valueOf(i).toString();
  63         ByteBuffer bf = ByteBuffer.allocate(8);
  64         bf.putInt(0, i);
  65         bf.putInt(4, i);
  66         v.l = bf.getLong(0);
  67         v.s1 = bf.getShort(2);
  68         v.s2 = bf.getShort(0);
  69         v.b1 = bf.get(3);
  70         v.b2 = bf.get(2);
  71         v.b3 = bf.get(1);
  72         v.b4 = bf.get(0);
  73         return v;
  74     }
  75 
  76     public static TestValue4 create() {
  77         return create((int)System.nanoTime());
  78     }
  79 
  80     public static TestValue4 getInstance() {
  81         return create();
  82     }
  83 
  84     public static TestValue4 getNonBufferedInstance() {
  85         return staticValue;
  86     }
  87 
  88     public boolean verify() {
  89         if (val == null) {
  90             return i == 0 && l == 0 && b1 == 0 && b2 == 0 && b3 == 0 && b4 == 0
  91                     && s1 == 0 && s2 == 0;
  92         }
  93         ByteBuffer bf = ByteBuffer.allocate(8);
  94         bf.putInt(0, i);
  95         bf.putInt(4, i);
  96         long nl =  bf.getLong(0);
< prev index next >