< prev index next >

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

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


 126 
 127     @DataProvider
 128     public Object[][] varHandlesProvider() throws Exception {
 129         List<VarHandle> vhs = new ArrayList<>();
 130         vhs.add(vhField);
 131         vhs.add(vhStaticField);
 132         vhs.add(vhArray);
 133 
 134         return vhs.stream().map(tc -> new Object[]{tc}).toArray(Object[][]::new);
 135     }
 136 
 137     @Test
 138     public void testEqualsAndHashCode() {
 139         VarHandle[] vhs1 = allocate(true);
 140         VarHandle[] vhs2 = allocate(true);
 141 
 142         for (int i = 0; i < vhs1.length; i++) {
 143             for (int j = 0; j < vhs1.length; j++) {
 144                 if (i == j) {
 145                     assertEquals(vhs1[i], vhs1[i]);
 146                     assertEquals(vhs1[i], vhs2[i]);
 147                     assertEquals(vhs1[i].hashCode(), vhs2[i].hashCode());
 148                 }
 149                 else {
 150                     assertNotEquals(vhs1[i], vhs1[j]);
 151                     assertNotEquals(vhs1[i], vhs2[j]);
 152                 }
 153             }
 154         }
 155 
 156         VarHandle[] vhs3 = allocate(false);
 157         for (int i = 0; i < vhs1.length; i++) {
 158             assertNotEquals(vhs1[i], vhs3[i]);
 159         }
 160     }
 161 
 162     @Test(dataProvider = "varHandlesProvider")
 163     public void testIsAccessModeSupported(VarHandle vh) {
 164         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
 165         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
 166         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
 167         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));




 126 
 127     @DataProvider
 128     public Object[][] varHandlesProvider() throws Exception {
 129         List<VarHandle> vhs = new ArrayList<>();
 130         vhs.add(vhField);
 131         vhs.add(vhStaticField);
 132         vhs.add(vhArray);
 133 
 134         return vhs.stream().map(tc -> new Object[]{tc}).toArray(Object[][]::new);
 135     }
 136 
 137     @Test
 138     public void testEqualsAndHashCode() {
 139         VarHandle[] vhs1 = allocate(true);
 140         VarHandle[] vhs2 = allocate(true);
 141 
 142         for (int i = 0; i < vhs1.length; i++) {
 143             for (int j = 0; j < vhs1.length; j++) {
 144                 if (i == j) {
 145                     assertEquals(vhs1[i], vhs1[i]);


 146                 }
 147                 else {
 148                     assertNotEquals(vhs1[i], vhs1[j]);
 149                     assertNotEquals(vhs1[i], vhs2[j]);
 150                 }
 151             }
 152         }
 153 
 154         VarHandle[] vhs3 = allocate(false);
 155         for (int i = 0; i < vhs1.length; i++) {
 156             assertNotEquals(vhs1[i], vhs3[i]);
 157         }
 158     }
 159 
 160     @Test(dataProvider = "varHandlesProvider")
 161     public void testIsAccessModeSupported(VarHandle vh) {
 162         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
 163         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
 164         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
 165         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));


< prev index next >