< prev index next >

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

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


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




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


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


< prev index next >