88 return vhs.stream().map(tc -> new Object[]{tc}).toArray(Object[][]::new); |
88 return vhs.stream().map(tc -> new Object[]{tc}).toArray(Object[][]::new); |
89 } |
89 } |
90 |
90 |
91 @Test(dataProvider = "varHandlesProvider") |
91 @Test(dataProvider = "varHandlesProvider") |
92 public void testIsAccessModeSupported(VarHandle vh) { |
92 public void testIsAccessModeSupported(VarHandle vh) { |
93 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get)); |
93 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET)); |
94 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set)); |
94 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET)); |
95 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile)); |
95 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE)); |
96 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile)); |
96 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE)); |
97 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire)); |
97 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE)); |
98 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease)); |
98 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE)); |
99 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque)); |
99 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE)); |
100 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque)); |
100 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE)); |
101 |
101 |
102 #if[CAS] |
102 #if[CAS] |
103 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet)); |
103 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); |
104 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile)); |
104 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE)); |
105 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire)); |
105 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); |
106 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease)); |
106 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); |
107 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet)); |
107 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); |
108 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire)); |
108 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); |
109 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease)); |
109 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); |
110 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease)); |
110 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); |
111 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet)); |
|
112 #else[CAS] |
111 #else[CAS] |
113 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet)); |
112 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); |
114 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile)); |
113 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE)); |
115 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire)); |
114 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); |
116 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease)); |
115 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); |
117 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet)); |
116 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); |
118 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire)); |
117 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); |
119 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease)); |
118 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); |
120 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease)); |
119 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); |
121 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet)); |
|
122 #end[CAS] |
120 #end[CAS] |
123 |
121 |
124 #if[AtomicAdd] |
122 #if[AtomicAdd] |
125 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd)); |
123 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); |
126 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet)); |
124 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); |
127 #else[AtomicAdd] |
125 #else[AtomicAdd] |
128 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd)); |
126 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); |
129 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet)); |
127 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); |
130 #end[AtomicAdd] |
128 #end[AtomicAdd] |
131 } |
129 } |
132 |
130 |
133 |
131 |
134 @DataProvider |
132 @DataProvider |