< prev index next >

test/jdk/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java

Print this page
rev 53074 : 8215648: remove equals and hashCode implementations from j.l.i.VarHandle


  76 
  77             VarHandleSource bbh = new VarHandleSource(
  78                     MethodHandles.byteBufferViewVarHandle(arrayType, bo),
  79                     endianess, MemoryMode.READ_WRITE);
  80             vhss.add(bbh);
  81         }
  82         return vhss;
  83     }
  84 
  85     @Test
  86     public void testEqualsAndHashCode() {
  87         VarHandle[] vhs1 = setupVarHandleSources(true).stream().
  88             map(vhs -> vhs.s).toArray(VarHandle[]::new);
  89         VarHandle[] vhs2 = setupVarHandleSources(true).stream().
  90             map(vhs -> vhs.s).toArray(VarHandle[]::new);
  91 
  92         for (int i = 0; i < vhs1.length; i++) {
  93             for (int j = 0; j < vhs1.length; j++) {
  94                 if (i == j) {
  95                     assertEquals(vhs1[i], vhs1[i]);
  96                     assertEquals(vhs1[i], vhs2[i]);
  97                     assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
  98                 }
  99                 else {
 100                     assertNotEquals(vhs1[i], vhs1[j]);
 101                     assertNotEquals(vhs1[i], vhs2[j]);
 102                 }
 103             }
 104         }
 105 
 106         VarHandle[] vhs3 = setupVarHandleSources(false).stream().
 107             map(vhs -> vhs.s).toArray(VarHandle[]::new);
 108         for (int i = 0; i < vhs1.length; i++) {
 109             assertNotEquals(vhs1[i], vhs3[i]);
 110         }
 111     }
 112 
 113     @Test(dataProvider = "varHandlesProvider")
 114     public void testIsAccessModeSupported(VarHandleSource vhs) {
 115         VarHandle vh = vhs.s;
 116 
 117         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));




  76 
  77             VarHandleSource bbh = new VarHandleSource(
  78                     MethodHandles.byteBufferViewVarHandle(arrayType, bo),
  79                     endianess, MemoryMode.READ_WRITE);
  80             vhss.add(bbh);
  81         }
  82         return vhss;
  83     }
  84 
  85     @Test
  86     public void testEqualsAndHashCode() {
  87         VarHandle[] vhs1 = setupVarHandleSources(true).stream().
  88             map(vhs -> vhs.s).toArray(VarHandle[]::new);
  89         VarHandle[] vhs2 = setupVarHandleSources(true).stream().
  90             map(vhs -> vhs.s).toArray(VarHandle[]::new);
  91 
  92         for (int i = 0; i < vhs1.length; i++) {
  93             for (int j = 0; j < vhs1.length; j++) {
  94                 if (i == j) {
  95                     assertEquals(vhs1[i], vhs1[i]);


  96                 }
  97                 else {
  98                     assertNotEquals(vhs1[i], vhs1[j]);
  99                     assertNotEquals(vhs1[i], vhs2[j]);
 100                 }
 101             }
 102         }
 103 
 104         VarHandle[] vhs3 = setupVarHandleSources(false).stream().
 105             map(vhs -> vhs.s).toArray(VarHandle[]::new);
 106         for (int i = 0; i < vhs1.length; i++) {
 107             assertNotEquals(vhs1[i], vhs3[i]);
 108         }
 109     }
 110 
 111     @Test(dataProvider = "varHandlesProvider")
 112     public void testIsAccessModeSupported(VarHandleSource vhs) {
 113         VarHandle vh = vhs.s;
 114 
 115         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));


< prev index next >