74 |
74 |
75 @Test(dataProvider = "varHandlesProvider") |
75 @Test(dataProvider = "varHandlesProvider") |
76 public void testIsAccessModeSupported(VarHandleSource vhs) { |
76 public void testIsAccessModeSupported(VarHandleSource vhs) { |
77 VarHandle vh = vhs.s; |
77 VarHandle vh = vhs.s; |
78 |
78 |
79 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.get)); |
79 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET)); |
80 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.set)); |
80 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET)); |
81 |
81 |
82 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getVolatile)); |
82 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE)); |
83 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setVolatile)); |
83 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE)); |
84 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAcquire)); |
84 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE)); |
85 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setRelease)); |
85 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE)); |
86 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getOpaque)); |
86 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE)); |
87 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.setOpaque)); |
87 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE)); |
88 |
88 |
89 #if[CAS] |
89 #if[CAS] |
90 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet)); |
90 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); |
91 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile)); |
91 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE)); |
92 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire)); |
92 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); |
93 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease)); |
93 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); |
94 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet)); |
94 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); |
95 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire)); |
95 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); |
96 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease)); |
96 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); |
97 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease)); |
97 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); |
98 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet)); |
|
99 #else[CAS] |
98 #else[CAS] |
100 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndSet)); |
99 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); |
101 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeVolatile)); |
100 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE)); |
102 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeAcquire)); |
101 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); |
103 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.compareAndExchangeRelease)); |
102 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); |
104 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSet)); |
103 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); |
105 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetAcquire)); |
104 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); |
106 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease)); |
105 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); |
107 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.weakCompareAndSetRelease)); |
106 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); |
108 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndSet)); |
|
109 #end[CAS] |
107 #end[CAS] |
110 |
108 |
111 #if[AtomicAdd] |
109 #if[AtomicAdd] |
112 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd)); |
110 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); |
113 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet)); |
111 assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); |
114 #else[AtomicAdd] |
112 #else[AtomicAdd] |
115 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.getAndAdd)); |
113 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); |
116 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.addAndGet)); |
114 assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); |
117 #end[AtomicAdd] |
115 #end[AtomicAdd] |
118 } |
116 } |
119 |
117 |
120 @Test(dataProvider = "typesProvider") |
118 @Test(dataProvider = "typesProvider") |
121 public void testTypes(VarHandle vh, List<java.lang.Class<?>> pts) { |
119 public void testTypes(VarHandle vh, List<java.lang.Class<?>> pts) { |