author | amurillo |
Tue, 17 May 2016 05:38:15 -0700 | |
changeset 38368 | c8eb5d6812c5 |
parent 38328 | 40435a469d25 |
child 39472 | 6df82f4c63ac |
permissions | -rw-r--r-- |
36934 | 1 |
/* |
2 |
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
26 |
* @bug 8156486 |
36934 | 27 |
* @run testng/othervm VarHandleTestMethodType$Type$ |
28 |
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodType$Type$ |
|
29 |
*/ |
|
30 |
||
31 |
import org.testng.annotations.BeforeClass; |
|
32 |
import org.testng.annotations.DataProvider; |
|
33 |
import org.testng.annotations.Test; |
|
34 |
||
35 |
import java.lang.invoke.MethodHandles; |
|
36 |
import java.lang.invoke.VarHandle; |
|
37 |
import java.util.ArrayList; |
|
38 |
import java.util.Arrays; |
|
39 |
import java.util.List; |
|
40 |
||
41 |
import static org.testng.Assert.*; |
|
42 |
||
43 |
import static java.lang.invoke.MethodType.*; |
|
44 |
||
45 |
public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { |
|
46 |
static final $type$ static_final_v = $value1$; |
|
47 |
||
48 |
static $type$ static_v = $value1$; |
|
49 |
||
50 |
final $type$ final_v = $value1$; |
|
51 |
||
52 |
$type$ v = $value1$; |
|
53 |
||
54 |
VarHandle vhFinalField; |
|
55 |
||
56 |
VarHandle vhField; |
|
57 |
||
58 |
VarHandle vhStaticField; |
|
59 |
||
60 |
VarHandle vhStaticFinalField; |
|
61 |
||
62 |
VarHandle vhArray; |
|
63 |
||
64 |
@BeforeClass |
|
65 |
public void setup() throws Exception { |
|
66 |
vhFinalField = MethodHandles.lookup().findVarHandle( |
|
67 |
VarHandleTestMethodType$Type$.class, "final_v", $type$.class); |
|
68 |
||
69 |
vhField = MethodHandles.lookup().findVarHandle( |
|
70 |
VarHandleTestMethodType$Type$.class, "v", $type$.class); |
|
71 |
||
72 |
vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle( |
|
73 |
VarHandleTestMethodType$Type$.class, "static_final_v", $type$.class); |
|
74 |
||
75 |
vhStaticField = MethodHandles.lookup().findStaticVarHandle( |
|
76 |
VarHandleTestMethodType$Type$.class, "static_v", $type$.class); |
|
77 |
||
78 |
vhArray = MethodHandles.arrayElementVarHandle($type$[].class); |
|
79 |
} |
|
80 |
||
81 |
@DataProvider |
|
82 |
public Object[][] accessTestCaseProvider() throws Exception { |
|
83 |
List<AccessTestCase<?>> cases = new ArrayList<>(); |
|
84 |
||
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
85 |
cases.add(new VarHandleAccessTestCase("Instance field", |
36934 | 86 |
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), |
87 |
false)); |
|
88 |
||
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
89 |
cases.add(new VarHandleAccessTestCase("Static field", |
36934 | 90 |
vhStaticField, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType, |
91 |
false)); |
|
92 |
||
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
93 |
cases.add(new VarHandleAccessTestCase("Array", |
36934 | 94 |
vhArray, VarHandleTestMethodType$Type$::testArrayWrongMethodType, |
95 |
false)); |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
96 |
|
36934 | 97 |
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
98 |
cases.add(new MethodHandleAccessTestCase("Instance field", |
36934 | 99 |
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), |
100 |
false)); |
|
101 |
||
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
102 |
cases.add(new MethodHandleAccessTestCase("Static field", |
36934 | 103 |
vhStaticField, f, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType, |
104 |
false)); |
|
105 |
||
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
106 |
cases.add(new MethodHandleAccessTestCase("Array", |
36934 | 107 |
vhArray, f, VarHandleTestMethodType$Type$::testArrayWrongMethodType, |
108 |
false)); |
|
109 |
} |
|
110 |
// Work around issue with jtreg summary reporting which truncates |
|
111 |
// the String result of Object.toString to 30 characters, hence |
|
112 |
// the first dummy argument |
|
113 |
return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new); |
|
114 |
} |
|
115 |
||
116 |
@Test(dataProvider = "accessTestCaseProvider") |
|
117 |
public <T> void testAccess(String desc, AccessTestCase<T> atc) throws Throwable { |
|
118 |
T t = atc.get(); |
|
119 |
int iters = atc.requiresLoop() ? ITERS : 1; |
|
120 |
for (int c = 0; c < iters; c++) { |
|
121 |
atc.testAccess(t); |
|
122 |
} |
|
123 |
} |
|
124 |
||
125 |
||
126 |
static void testInstanceFieldWrongMethodType(VarHandleTestMethodType$Type$ recv, VarHandle vh) throws Throwable { |
|
127 |
// Get |
|
128 |
// Incorrect argument types |
|
129 |
checkNPE(() -> { // null receiver |
|
130 |
$type$ x = ($type$) vh.get(null); |
|
131 |
}); |
|
132 |
checkCCE(() -> { // receiver reference class |
|
133 |
$type$ x = ($type$) vh.get(Void.class); |
|
134 |
}); |
|
135 |
checkWMTE(() -> { // receiver primitive class |
|
136 |
$type$ x = ($type$) vh.get(0); |
|
137 |
}); |
|
138 |
// Incorrect return type |
|
139 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
140 |
Void x = (Void) vh.get(recv); |
|
141 |
}); |
|
142 |
checkWMTE(() -> { // primitive class |
|
143 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.get(recv); |
|
144 |
}); |
|
145 |
// Incorrect arity |
|
146 |
checkWMTE(() -> { // 0 |
|
147 |
$type$ x = ($type$) vh.get(); |
|
148 |
}); |
|
149 |
checkWMTE(() -> { // > |
|
150 |
$type$ x = ($type$) vh.get(recv, Void.class); |
|
151 |
}); |
|
152 |
||
153 |
||
154 |
// Set |
|
155 |
// Incorrect argument types |
|
156 |
checkNPE(() -> { // null receiver |
|
157 |
vh.set(null, $value1$); |
|
158 |
}); |
|
159 |
checkCCE(() -> { // receiver reference class |
|
160 |
vh.set(Void.class, $value1$); |
|
161 |
}); |
|
162 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
163 |
vh.set(recv, Void.class); |
|
164 |
}); |
|
165 |
checkWMTE(() -> { // receiver primitive class |
|
166 |
vh.set(0, $value1$); |
|
167 |
}); |
|
168 |
// Incorrect arity |
|
169 |
checkWMTE(() -> { // 0 |
|
170 |
vh.set(); |
|
171 |
}); |
|
172 |
checkWMTE(() -> { // > |
|
173 |
vh.set(recv, $value1$, Void.class); |
|
174 |
}); |
|
175 |
||
176 |
||
177 |
// GetVolatile |
|
178 |
// Incorrect argument types |
|
179 |
checkNPE(() -> { // null receiver |
|
180 |
$type$ x = ($type$) vh.getVolatile(null); |
|
181 |
}); |
|
182 |
checkCCE(() -> { // receiver reference class |
|
183 |
$type$ x = ($type$) vh.getVolatile(Void.class); |
|
184 |
}); |
|
185 |
checkWMTE(() -> { // receiver primitive class |
|
186 |
$type$ x = ($type$) vh.getVolatile(0); |
|
187 |
}); |
|
188 |
// Incorrect return type |
|
189 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
190 |
Void x = (Void) vh.getVolatile(recv); |
|
191 |
}); |
|
192 |
checkWMTE(() -> { // primitive class |
|
193 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getVolatile(recv); |
|
194 |
}); |
|
195 |
// Incorrect arity |
|
196 |
checkWMTE(() -> { // 0 |
|
197 |
$type$ x = ($type$) vh.getVolatile(); |
|
198 |
}); |
|
199 |
checkWMTE(() -> { // > |
|
200 |
$type$ x = ($type$) vh.getVolatile(recv, Void.class); |
|
201 |
}); |
|
202 |
||
203 |
||
204 |
// SetVolatile |
|
205 |
// Incorrect argument types |
|
206 |
checkNPE(() -> { // null receiver |
|
207 |
vh.setVolatile(null, $value1$); |
|
208 |
}); |
|
209 |
checkCCE(() -> { // receiver reference class |
|
210 |
vh.setVolatile(Void.class, $value1$); |
|
211 |
}); |
|
212 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
213 |
vh.setVolatile(recv, Void.class); |
|
214 |
}); |
|
215 |
checkWMTE(() -> { // receiver primitive class |
|
216 |
vh.setVolatile(0, $value1$); |
|
217 |
}); |
|
218 |
// Incorrect arity |
|
219 |
checkWMTE(() -> { // 0 |
|
220 |
vh.setVolatile(); |
|
221 |
}); |
|
222 |
checkWMTE(() -> { // > |
|
223 |
vh.setVolatile(recv, $value1$, Void.class); |
|
224 |
}); |
|
225 |
||
226 |
||
227 |
// GetOpaque |
|
228 |
// Incorrect argument types |
|
229 |
checkNPE(() -> { // null receiver |
|
230 |
$type$ x = ($type$) vh.getOpaque(null); |
|
231 |
}); |
|
232 |
checkCCE(() -> { // receiver reference class |
|
233 |
$type$ x = ($type$) vh.getOpaque(Void.class); |
|
234 |
}); |
|
235 |
checkWMTE(() -> { // receiver primitive class |
|
236 |
$type$ x = ($type$) vh.getOpaque(0); |
|
237 |
}); |
|
238 |
// Incorrect return type |
|
239 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
240 |
Void x = (Void) vh.getOpaque(recv); |
|
241 |
}); |
|
242 |
checkWMTE(() -> { // primitive class |
|
243 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getOpaque(recv); |
|
244 |
}); |
|
245 |
// Incorrect arity |
|
246 |
checkWMTE(() -> { // 0 |
|
247 |
$type$ x = ($type$) vh.getOpaque(); |
|
248 |
}); |
|
249 |
checkWMTE(() -> { // > |
|
250 |
$type$ x = ($type$) vh.getOpaque(recv, Void.class); |
|
251 |
}); |
|
252 |
||
253 |
||
254 |
// SetOpaque |
|
255 |
// Incorrect argument types |
|
256 |
checkNPE(() -> { // null receiver |
|
257 |
vh.setOpaque(null, $value1$); |
|
258 |
}); |
|
259 |
checkCCE(() -> { // receiver reference class |
|
260 |
vh.setOpaque(Void.class, $value1$); |
|
261 |
}); |
|
262 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
263 |
vh.setOpaque(recv, Void.class); |
|
264 |
}); |
|
265 |
checkWMTE(() -> { // receiver primitive class |
|
266 |
vh.setOpaque(0, $value1$); |
|
267 |
}); |
|
268 |
// Incorrect arity |
|
269 |
checkWMTE(() -> { // 0 |
|
270 |
vh.setOpaque(); |
|
271 |
}); |
|
272 |
checkWMTE(() -> { // > |
|
273 |
vh.setOpaque(recv, $value1$, Void.class); |
|
274 |
}); |
|
275 |
||
276 |
||
277 |
// GetAcquire |
|
278 |
// Incorrect argument types |
|
279 |
checkNPE(() -> { // null receiver |
|
280 |
$type$ x = ($type$) vh.getAcquire(null); |
|
281 |
}); |
|
282 |
checkCCE(() -> { // receiver reference class |
|
283 |
$type$ x = ($type$) vh.getAcquire(Void.class); |
|
284 |
}); |
|
285 |
checkWMTE(() -> { // receiver primitive class |
|
286 |
$type$ x = ($type$) vh.getAcquire(0); |
|
287 |
}); |
|
288 |
// Incorrect return type |
|
289 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
290 |
Void x = (Void) vh.getAcquire(recv); |
|
291 |
}); |
|
292 |
checkWMTE(() -> { // primitive class |
|
293 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAcquire(recv); |
|
294 |
}); |
|
295 |
// Incorrect arity |
|
296 |
checkWMTE(() -> { // 0 |
|
297 |
$type$ x = ($type$) vh.getAcquire(); |
|
298 |
}); |
|
299 |
checkWMTE(() -> { // > |
|
300 |
$type$ x = ($type$) vh.getAcquire(recv, Void.class); |
|
301 |
}); |
|
302 |
||
303 |
||
304 |
// SetRelease |
|
305 |
// Incorrect argument types |
|
306 |
checkNPE(() -> { // null receiver |
|
307 |
vh.setRelease(null, $value1$); |
|
308 |
}); |
|
309 |
checkCCE(() -> { // receiver reference class |
|
310 |
vh.setRelease(Void.class, $value1$); |
|
311 |
}); |
|
312 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
313 |
vh.setRelease(recv, Void.class); |
|
314 |
}); |
|
315 |
checkWMTE(() -> { // receiver primitive class |
|
316 |
vh.setRelease(0, $value1$); |
|
317 |
}); |
|
318 |
// Incorrect arity |
|
319 |
checkWMTE(() -> { // 0 |
|
320 |
vh.setRelease(); |
|
321 |
}); |
|
322 |
checkWMTE(() -> { // > |
|
323 |
vh.setRelease(recv, $value1$, Void.class); |
|
324 |
}); |
|
325 |
||
326 |
||
327 |
#if[CAS] |
|
328 |
// CompareAndSet |
|
329 |
// Incorrect argument types |
|
330 |
checkNPE(() -> { // null receiver |
|
331 |
boolean r = vh.compareAndSet(null, $value1$, $value1$); |
|
332 |
}); |
|
333 |
checkCCE(() -> { // receiver reference class |
|
334 |
boolean r = vh.compareAndSet(Void.class, $value1$, $value1$); |
|
335 |
}); |
|
336 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
337 |
boolean r = vh.compareAndSet(recv, Void.class, $value1$); |
|
338 |
}); |
|
339 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
340 |
boolean r = vh.compareAndSet(recv, $value1$, Void.class); |
|
341 |
}); |
|
342 |
checkWMTE(() -> { // receiver primitive class |
|
343 |
boolean r = vh.compareAndSet(0, $value1$, $value1$); |
|
344 |
}); |
|
345 |
// Incorrect arity |
|
346 |
checkWMTE(() -> { // 0 |
|
347 |
boolean r = vh.compareAndSet(); |
|
348 |
}); |
|
349 |
checkWMTE(() -> { // > |
|
350 |
boolean r = vh.compareAndSet(recv, $value1$, $value1$, Void.class); |
|
351 |
}); |
|
352 |
||
353 |
||
354 |
// WeakCompareAndSet |
|
355 |
// Incorrect argument types |
|
356 |
checkNPE(() -> { // null receiver |
|
357 |
boolean r = vh.weakCompareAndSet(null, $value1$, $value1$); |
|
358 |
}); |
|
359 |
checkCCE(() -> { // receiver reference class |
|
360 |
boolean r = vh.weakCompareAndSet(Void.class, $value1$, $value1$); |
|
361 |
}); |
|
362 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
363 |
boolean r = vh.weakCompareAndSet(recv, Void.class, $value1$); |
|
364 |
}); |
|
365 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
366 |
boolean r = vh.weakCompareAndSet(recv, $value1$, Void.class); |
|
367 |
}); |
|
368 |
checkWMTE(() -> { // receiver primitive class |
|
369 |
boolean r = vh.weakCompareAndSet(0, $value1$, $value1$); |
|
370 |
}); |
|
371 |
// Incorrect arity |
|
372 |
checkWMTE(() -> { // 0 |
|
373 |
boolean r = vh.weakCompareAndSet(); |
|
374 |
}); |
|
375 |
checkWMTE(() -> { // > |
|
376 |
boolean r = vh.weakCompareAndSet(recv, $value1$, $value1$, Void.class); |
|
377 |
}); |
|
378 |
||
379 |
||
37719
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
380 |
// WeakCompareAndSetVolatile |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
381 |
// Incorrect argument types |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
382 |
checkNPE(() -> { // null receiver |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
383 |
boolean r = vh.weakCompareAndSetVolatile(null, $value1$, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
384 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
385 |
checkCCE(() -> { // receiver reference class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
386 |
boolean r = vh.weakCompareAndSetVolatile(Void.class, $value1$, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
387 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
388 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
389 |
boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
390 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
391 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
392 |
boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, Void.class); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
393 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
394 |
checkWMTE(() -> { // receiver primitive class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
395 |
boolean r = vh.weakCompareAndSetVolatile(0, $value1$, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
396 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
397 |
// Incorrect arity |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
398 |
checkWMTE(() -> { // 0 |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
399 |
boolean r = vh.weakCompareAndSetVolatile(); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
400 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
401 |
checkWMTE(() -> { // > |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
402 |
boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, $value1$, Void.class); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
403 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
404 |
|
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
405 |
|
36934 | 406 |
// WeakCompareAndSetAcquire |
407 |
// Incorrect argument types |
|
408 |
checkNPE(() -> { // null receiver |
|
409 |
boolean r = vh.weakCompareAndSetAcquire(null, $value1$, $value1$); |
|
410 |
}); |
|
411 |
checkCCE(() -> { // receiver reference class |
|
412 |
boolean r = vh.weakCompareAndSetAcquire(Void.class, $value1$, $value1$); |
|
413 |
}); |
|
414 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
415 |
boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, $value1$); |
|
416 |
}); |
|
417 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
418 |
boolean r = vh.weakCompareAndSetAcquire(recv, $value1$, Void.class); |
|
419 |
}); |
|
420 |
checkWMTE(() -> { // receiver primitive class |
|
421 |
boolean r = vh.weakCompareAndSetAcquire(0, $value1$, $value1$); |
|
422 |
}); |
|
423 |
// Incorrect arity |
|
424 |
checkWMTE(() -> { // 0 |
|
425 |
boolean r = vh.weakCompareAndSetAcquire(); |
|
426 |
}); |
|
427 |
checkWMTE(() -> { // > |
|
428 |
boolean r = vh.weakCompareAndSetAcquire(recv, $value1$, $value1$, Void.class); |
|
429 |
}); |
|
430 |
||
431 |
||
432 |
// WeakCompareAndSetRelease |
|
433 |
// Incorrect argument types |
|
434 |
checkNPE(() -> { // null receiver |
|
435 |
boolean r = vh.weakCompareAndSetRelease(null, $value1$, $value1$); |
|
436 |
}); |
|
437 |
checkCCE(() -> { // receiver reference class |
|
438 |
boolean r = vh.weakCompareAndSetRelease(Void.class, $value1$, $value1$); |
|
439 |
}); |
|
440 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
441 |
boolean r = vh.weakCompareAndSetRelease(recv, Void.class, $value1$); |
|
442 |
}); |
|
443 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
444 |
boolean r = vh.weakCompareAndSetRelease(recv, $value1$, Void.class); |
|
445 |
}); |
|
446 |
checkWMTE(() -> { // receiver primitive class |
|
447 |
boolean r = vh.weakCompareAndSetRelease(0, $value1$, $value1$); |
|
448 |
}); |
|
449 |
// Incorrect arity |
|
450 |
checkWMTE(() -> { // 0 |
|
451 |
boolean r = vh.weakCompareAndSetRelease(); |
|
452 |
}); |
|
453 |
checkWMTE(() -> { // > |
|
454 |
boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value1$, Void.class); |
|
455 |
}); |
|
456 |
||
457 |
||
458 |
// CompareAndExchangeVolatile |
|
459 |
// Incorrect argument types |
|
460 |
checkNPE(() -> { // null receiver |
|
461 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(null, $value1$, $value1$); |
|
462 |
}); |
|
463 |
checkCCE(() -> { // receiver reference class |
|
464 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(Void.class, $value1$, $value1$); |
|
465 |
}); |
|
466 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
467 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(recv, Void.class, $value1$); |
|
468 |
}); |
|
469 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
470 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(recv, $value1$, Void.class); |
|
471 |
}); |
|
472 |
checkWMTE(() -> { // reciever primitive class |
|
473 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(0, $value1$, $value1$); |
|
474 |
}); |
|
475 |
// Incorrect return type |
|
476 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
477 |
Void r = (Void) vh.compareAndExchangeVolatile(recv, $value1$, $value1$); |
|
478 |
}); |
|
479 |
checkWMTE(() -> { // primitive class |
|
480 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.compareAndExchangeVolatile(recv, $value1$, $value1$); |
|
481 |
}); |
|
482 |
// Incorrect arity |
|
483 |
checkWMTE(() -> { // 0 |
|
484 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(); |
|
485 |
}); |
|
486 |
checkWMTE(() -> { // > |
|
487 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(recv, $value1$, $value1$, Void.class); |
|
488 |
}); |
|
489 |
||
490 |
||
491 |
// CompareAndExchangeVolatileAcquire |
|
492 |
// Incorrect argument types |
|
493 |
checkNPE(() -> { // null receiver |
|
494 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(null, $value1$, $value1$); |
|
495 |
}); |
|
496 |
checkCCE(() -> { // receiver reference class |
|
497 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(Void.class, $value1$, $value1$); |
|
498 |
}); |
|
499 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
500 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(recv, Void.class, $value1$); |
|
501 |
}); |
|
502 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
503 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(recv, $value1$, Void.class); |
|
504 |
}); |
|
505 |
checkWMTE(() -> { // reciever primitive class |
|
506 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(0, $value1$, $value1$); |
|
507 |
}); |
|
508 |
// Incorrect return type |
|
509 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
510 |
Void r = (Void) vh.compareAndExchangeAcquire(recv, $value1$, $value1$); |
|
511 |
}); |
|
512 |
checkWMTE(() -> { // primitive class |
|
513 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.compareAndExchangeAcquire(recv, $value1$, $value1$); |
|
514 |
}); |
|
515 |
// Incorrect arity |
|
516 |
checkWMTE(() -> { // 0 |
|
517 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(); |
|
518 |
}); |
|
519 |
checkWMTE(() -> { // > |
|
520 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(recv, $value1$, $value1$, Void.class); |
|
521 |
}); |
|
522 |
||
523 |
||
524 |
// CompareAndExchangeRelease |
|
525 |
// Incorrect argument types |
|
526 |
checkNPE(() -> { // null receiver |
|
527 |
$type$ x = ($type$) vh.compareAndExchangeRelease(null, $value1$, $value1$); |
|
528 |
}); |
|
529 |
checkCCE(() -> { // receiver reference class |
|
530 |
$type$ x = ($type$) vh.compareAndExchangeRelease(Void.class, $value1$, $value1$); |
|
531 |
}); |
|
532 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
533 |
$type$ x = ($type$) vh.compareAndExchangeRelease(recv, Void.class, $value1$); |
|
534 |
}); |
|
535 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
536 |
$type$ x = ($type$) vh.compareAndExchangeRelease(recv, $value1$, Void.class); |
|
537 |
}); |
|
538 |
checkWMTE(() -> { // reciever primitive class |
|
539 |
$type$ x = ($type$) vh.compareAndExchangeRelease(0, $value1$, $value1$); |
|
540 |
}); |
|
541 |
// Incorrect return type |
|
542 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
543 |
Void r = (Void) vh.compareAndExchangeRelease(recv, $value1$, $value1$); |
|
544 |
}); |
|
545 |
checkWMTE(() -> { // primitive class |
|
546 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.compareAndExchangeRelease(recv, $value1$, $value1$); |
|
547 |
}); |
|
548 |
// Incorrect arity |
|
549 |
checkWMTE(() -> { // 0 |
|
550 |
$type$ x = ($type$) vh.compareAndExchangeRelease(); |
|
551 |
}); |
|
552 |
checkWMTE(() -> { // > |
|
553 |
$type$ x = ($type$) vh.compareAndExchangeRelease(recv, $value1$, $value1$, Void.class); |
|
554 |
}); |
|
555 |
||
556 |
||
557 |
// GetAndSet |
|
558 |
// Incorrect argument types |
|
559 |
checkNPE(() -> { // null receiver |
|
560 |
$type$ x = ($type$) vh.getAndSet(null, $value1$); |
|
561 |
}); |
|
562 |
checkCCE(() -> { // receiver reference class |
|
563 |
$type$ x = ($type$) vh.getAndSet(Void.class, $value1$); |
|
564 |
}); |
|
565 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
566 |
$type$ x = ($type$) vh.getAndSet(recv, Void.class); |
|
567 |
}); |
|
568 |
checkWMTE(() -> { // reciever primitive class |
|
569 |
$type$ x = ($type$) vh.getAndSet(0, $value1$); |
|
570 |
}); |
|
571 |
// Incorrect return type |
|
572 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
573 |
Void r = (Void) vh.getAndSet(recv, $value1$); |
|
574 |
}); |
|
575 |
checkWMTE(() -> { // primitive class |
|
576 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSet(recv, $value1$); |
|
577 |
}); |
|
578 |
// Incorrect arity |
|
579 |
checkWMTE(() -> { // 0 |
|
580 |
$type$ x = ($type$) vh.getAndSet(); |
|
581 |
}); |
|
582 |
checkWMTE(() -> { // > |
|
583 |
$type$ x = ($type$) vh.getAndSet(recv, $value1$, Void.class); |
|
584 |
}); |
|
585 |
#end[CAS] |
|
586 |
||
587 |
#if[AtomicAdd] |
|
588 |
// GetAndAdd |
|
589 |
// Incorrect argument types |
|
590 |
checkNPE(() -> { // null receiver |
|
591 |
$type$ x = ($type$) vh.getAndAdd(null, $value1$); |
|
592 |
}); |
|
593 |
checkCCE(() -> { // receiver reference class |
|
594 |
$type$ x = ($type$) vh.getAndAdd(Void.class, $value1$); |
|
595 |
}); |
|
596 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
597 |
$type$ x = ($type$) vh.getAndAdd(recv, Void.class); |
|
598 |
}); |
|
599 |
checkWMTE(() -> { // reciever primitive class |
|
600 |
$type$ x = ($type$) vh.getAndAdd(0, $value1$); |
|
601 |
}); |
|
602 |
// Incorrect return type |
|
603 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
604 |
Void r = (Void) vh.getAndAdd(recv, $value1$); |
|
605 |
}); |
|
606 |
checkWMTE(() -> { // primitive class |
|
607 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAdd(recv, $value1$); |
|
608 |
}); |
|
609 |
// Incorrect arity |
|
610 |
checkWMTE(() -> { // 0 |
|
611 |
$type$ x = ($type$) vh.getAndAdd(); |
|
612 |
}); |
|
613 |
checkWMTE(() -> { // > |
|
614 |
$type$ x = ($type$) vh.getAndAdd(recv, $value1$, Void.class); |
|
615 |
}); |
|
616 |
||
617 |
||
618 |
// AddAndGet |
|
619 |
// Incorrect argument types |
|
620 |
checkNPE(() -> { // null receiver |
|
621 |
$type$ x = ($type$) vh.addAndGet(null, $value1$); |
|
622 |
}); |
|
623 |
checkCCE(() -> { // receiver reference class |
|
624 |
$type$ x = ($type$) vh.addAndGet(Void.class, $value1$); |
|
625 |
}); |
|
626 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
627 |
$type$ x = ($type$) vh.addAndGet(recv, Void.class); |
|
628 |
}); |
|
629 |
checkWMTE(() -> { // reciever primitive class |
|
630 |
$type$ x = ($type$) vh.addAndGet(0, $value1$); |
|
631 |
}); |
|
632 |
// Incorrect return type |
|
633 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
634 |
Void r = (Void) vh.addAndGet(recv, $value1$); |
|
635 |
}); |
|
636 |
checkWMTE(() -> { // primitive class |
|
637 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.addAndGet(recv, $value1$); |
|
638 |
}); |
|
639 |
// Incorrect arity |
|
640 |
checkWMTE(() -> { // 0 |
|
641 |
$type$ x = ($type$) vh.addAndGet(); |
|
642 |
}); |
|
643 |
checkWMTE(() -> { // > |
|
644 |
$type$ x = ($type$) vh.addAndGet(recv, $value1$, Void.class); |
|
645 |
}); |
|
646 |
#end[AtomicAdd] |
|
647 |
} |
|
648 |
||
649 |
static void testInstanceFieldWrongMethodType(VarHandleTestMethodType$Type$ recv, Handles hs) throws Throwable { |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
650 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { |
36934 | 651 |
// Incorrect argument types |
652 |
checkNPE(() -> { // null receiver |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
653 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
654 |
invokeExact((VarHandleTestMethodType$Type$) null); |
36934 | 655 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
656 |
hs.checkWMTEOrCCE(() -> { // receiver reference class |
36934 | 657 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
658 |
invokeExact(Void.class); |
36934 | 659 |
}); |
660 |
checkWMTE(() -> { // receiver primitive class |
|
661 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
662 |
invokeExact(0); |
36934 | 663 |
}); |
664 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
665 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
666 |
Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
667 |
invokeExact(recv); |
36934 | 668 |
}); |
669 |
checkWMTE(() -> { // primitive class |
|
670 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
671 |
invokeExact(recv); |
36934 | 672 |
}); |
673 |
// Incorrect arity |
|
674 |
checkWMTE(() -> { // 0 |
|
675 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
676 |
invokeExact(); |
36934 | 677 |
}); |
678 |
checkWMTE(() -> { // > |
|
679 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
680 |
invokeExact(recv, Void.class); |
36934 | 681 |
}); |
682 |
} |
|
683 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
684 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { |
36934 | 685 |
// Incorrect argument types |
686 |
checkNPE(() -> { // null receiver |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
687 |
hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
688 |
invokeExact((VarHandleTestMethodType$Type$) null, $value1$); |
36934 | 689 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
690 |
hs.checkWMTEOrCCE(() -> { // receiver reference class |
36934 | 691 |
hs.get(am, methodType(void.class, Class.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
692 |
invokeExact(Void.class, $value1$); |
36934 | 693 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
694 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class |
36934 | 695 |
hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
696 |
invokeExact(recv, Void.class); |
36934 | 697 |
}); |
698 |
checkWMTE(() -> { // receiver primitive class |
|
699 |
hs.get(am, methodType(void.class, int.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
700 |
invokeExact(0, $value1$); |
36934 | 701 |
}); |
702 |
// Incorrect arity |
|
703 |
checkWMTE(() -> { // 0 |
|
704 |
hs.get(am, methodType(void.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
705 |
invokeExact(); |
36934 | 706 |
}); |
707 |
checkWMTE(() -> { // > |
|
708 |
hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
709 |
invokeExact(recv, $value1$, Void.class); |
36934 | 710 |
}); |
711 |
} |
|
712 |
||
713 |
#if[CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
714 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { |
36934 | 715 |
// Incorrect argument types |
716 |
checkNPE(() -> { // null receiver |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
717 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
718 |
invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$); |
36934 | 719 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
720 |
hs.checkWMTEOrCCE(() -> { // receiver reference class |
36934 | 721 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
722 |
invokeExact(Void.class, $value1$, $value1$); |
36934 | 723 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
724 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class |
36934 | 725 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
726 |
invokeExact(recv, Void.class, $value1$); |
36934 | 727 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
728 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class |
36934 | 729 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
730 |
invokeExact(recv, $value1$, Void.class); |
36934 | 731 |
}); |
732 |
checkWMTE(() -> { // receiver primitive class |
|
733 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , $type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
734 |
invokeExact(0, $value1$, $value1$); |
36934 | 735 |
}); |
736 |
// Incorrect arity |
|
737 |
checkWMTE(() -> { // 0 |
|
738 |
boolean r = (boolean) hs.get(am, methodType(boolean.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
739 |
invokeExact(); |
36934 | 740 |
}); |
741 |
checkWMTE(() -> { // > |
|
742 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
743 |
invokeExact(recv, $value1$, $value1$, Void.class); |
36934 | 744 |
}); |
745 |
} |
|
746 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
747 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { |
36934 | 748 |
checkNPE(() -> { // null receiver |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
749 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
750 |
invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$); |
36934 | 751 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
752 |
hs.checkWMTEOrCCE(() -> { // receiver reference class |
36934 | 753 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
754 |
invokeExact(Void.class, $value1$, $value1$); |
36934 | 755 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
756 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class |
36934 | 757 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
758 |
invokeExact(recv, Void.class, $value1$); |
36934 | 759 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
760 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class |
36934 | 761 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
762 |
invokeExact(recv, $value1$, Void.class); |
36934 | 763 |
}); |
764 |
checkWMTE(() -> { // reciever primitive class |
|
765 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class , $type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
766 |
invokeExact(0, $value1$, $value1$); |
36934 | 767 |
}); |
768 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
769 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 770 |
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
771 |
invokeExact(recv, $value1$, $value1$); |
36934 | 772 |
}); |
773 |
checkWMTE(() -> { // primitive class |
|
774 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
775 |
invokeExact(recv, $value1$, $value1$); |
36934 | 776 |
}); |
777 |
// Incorrect arity |
|
778 |
checkWMTE(() -> { // 0 |
|
779 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
780 |
invokeExact(); |
36934 | 781 |
}); |
782 |
checkWMTE(() -> { // > |
|
783 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
784 |
invokeExact(recv, $value1$, $value1$, Void.class); |
36934 | 785 |
}); |
786 |
} |
|
787 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
788 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { |
36934 | 789 |
checkNPE(() -> { // null receiver |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
790 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
791 |
invokeExact((VarHandleTestMethodType$Type$) null, $value1$); |
36934 | 792 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
793 |
hs.checkWMTEOrCCE(() -> { // receiver reference class |
36934 | 794 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
795 |
invokeExact(Void.class, $value1$); |
36934 | 796 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
797 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class |
36934 | 798 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
799 |
invokeExact(recv, Void.class); |
36934 | 800 |
}); |
801 |
checkWMTE(() -> { // reciever primitive class |
|
802 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
803 |
invokeExact(0, $value1$); |
36934 | 804 |
}); |
805 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
806 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 807 |
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
808 |
invokeExact(recv, $value1$); |
36934 | 809 |
}); |
810 |
checkWMTE(() -> { // primitive class |
|
811 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
812 |
invokeExact(recv, $value1$); |
36934 | 813 |
}); |
814 |
// Incorrect arity |
|
815 |
checkWMTE(() -> { // 0 |
|
816 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
817 |
invokeExact(); |
36934 | 818 |
}); |
819 |
checkWMTE(() -> { // > |
|
820 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
821 |
invokeExact(recv, $value1$, Void.class); |
36934 | 822 |
}); |
823 |
} |
|
824 |
#end[CAS] |
|
825 |
||
826 |
#if[AtomicAdd] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
827 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { |
36934 | 828 |
checkNPE(() -> { // null receiver |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
829 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
830 |
invokeExact((VarHandleTestMethodType$Type$) null, $value1$); |
36934 | 831 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
832 |
hs.checkWMTEOrCCE(() -> { // receiver reference class |
36934 | 833 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
834 |
invokeExact(Void.class, $value1$); |
36934 | 835 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
836 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class |
36934 | 837 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
838 |
invokeExact(recv, Void.class); |
36934 | 839 |
}); |
840 |
checkWMTE(() -> { // reciever primitive class |
|
841 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
842 |
invokeExact(0, $value1$); |
36934 | 843 |
}); |
844 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
845 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 846 |
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
847 |
invokeExact(recv, $value1$); |
36934 | 848 |
}); |
849 |
checkWMTE(() -> { // primitive class |
|
850 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
851 |
invokeExact(recv, $value1$); |
36934 | 852 |
}); |
853 |
// Incorrect arity |
|
854 |
checkWMTE(() -> { // 0 |
|
855 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
856 |
invokeExact(); |
36934 | 857 |
}); |
858 |
checkWMTE(() -> { // > |
|
859 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
860 |
invokeExact(recv, $value1$, Void.class); |
36934 | 861 |
}); |
862 |
} |
|
863 |
#end[AtomicAdd] |
|
864 |
} |
|
865 |
||
866 |
||
867 |
static void testStaticFieldWrongMethodType(VarHandle vh) throws Throwable { |
|
868 |
// Get |
|
869 |
// Incorrect return type |
|
870 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
871 |
Void x = (Void) vh.get(); |
|
872 |
}); |
|
873 |
checkWMTE(() -> { // primitive class |
|
874 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.get(); |
|
875 |
}); |
|
876 |
// Incorrect arity |
|
877 |
checkWMTE(() -> { // > |
|
878 |
$type$ x = ($type$) vh.get(Void.class); |
|
879 |
}); |
|
880 |
||
881 |
||
882 |
// Set |
|
883 |
// Incorrect argument types |
|
884 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
885 |
vh.set(Void.class); |
|
886 |
}); |
|
887 |
// Incorrect arity |
|
888 |
checkWMTE(() -> { // 0 |
|
889 |
vh.set(); |
|
890 |
}); |
|
891 |
checkWMTE(() -> { // > |
|
892 |
vh.set($value1$, Void.class); |
|
893 |
}); |
|
894 |
||
895 |
||
896 |
// GetVolatile |
|
897 |
// Incorrect return type |
|
898 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
899 |
Void x = (Void) vh.getVolatile(); |
|
900 |
}); |
|
901 |
checkWMTE(() -> { // primitive class |
|
902 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getVolatile(); |
|
903 |
}); |
|
904 |
checkWMTE(() -> { // > |
|
905 |
$type$ x = ($type$) vh.getVolatile(Void.class); |
|
906 |
}); |
|
907 |
||
908 |
||
909 |
// SetVolatile |
|
910 |
// Incorrect argument types |
|
911 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
912 |
vh.setVolatile(Void.class); |
|
913 |
}); |
|
914 |
// Incorrect arity |
|
915 |
checkWMTE(() -> { // 0 |
|
916 |
vh.setVolatile(); |
|
917 |
}); |
|
918 |
checkWMTE(() -> { // > |
|
919 |
vh.setVolatile($value1$, Void.class); |
|
920 |
}); |
|
921 |
||
922 |
||
923 |
// GetOpaque |
|
924 |
// Incorrect return type |
|
925 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
926 |
Void x = (Void) vh.getOpaque(); |
|
927 |
}); |
|
928 |
checkWMTE(() -> { // primitive class |
|
929 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getOpaque(); |
|
930 |
}); |
|
931 |
checkWMTE(() -> { // > |
|
932 |
$type$ x = ($type$) vh.getOpaque(Void.class); |
|
933 |
}); |
|
934 |
||
935 |
||
936 |
// SetOpaque |
|
937 |
// Incorrect argument types |
|
938 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
939 |
vh.setOpaque(Void.class); |
|
940 |
}); |
|
941 |
// Incorrect arity |
|
942 |
checkWMTE(() -> { // 0 |
|
943 |
vh.setOpaque(); |
|
944 |
}); |
|
945 |
checkWMTE(() -> { // > |
|
946 |
vh.setOpaque($value1$, Void.class); |
|
947 |
}); |
|
948 |
||
949 |
||
950 |
// GetAcquire |
|
951 |
// Incorrect return type |
|
952 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
953 |
Void x = (Void) vh.getAcquire(); |
|
954 |
}); |
|
955 |
checkWMTE(() -> { // primitive class |
|
956 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAcquire(); |
|
957 |
}); |
|
958 |
checkWMTE(() -> { // > |
|
959 |
$type$ x = ($type$) vh.getAcquire(Void.class); |
|
960 |
}); |
|
961 |
||
962 |
||
963 |
// SetRelease |
|
964 |
// Incorrect argument types |
|
965 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
966 |
vh.setRelease(Void.class); |
|
967 |
}); |
|
968 |
// Incorrect arity |
|
969 |
checkWMTE(() -> { // 0 |
|
970 |
vh.setRelease(); |
|
971 |
}); |
|
972 |
checkWMTE(() -> { // > |
|
973 |
vh.setRelease($value1$, Void.class); |
|
974 |
}); |
|
975 |
||
976 |
||
977 |
#if[CAS] |
|
978 |
// CompareAndSet |
|
979 |
// Incorrect argument types |
|
980 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
981 |
boolean r = vh.compareAndSet(Void.class, $value1$); |
|
982 |
}); |
|
983 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
984 |
boolean r = vh.compareAndSet($value1$, Void.class); |
|
985 |
}); |
|
986 |
// Incorrect arity |
|
987 |
checkWMTE(() -> { // 0 |
|
988 |
boolean r = vh.compareAndSet(); |
|
989 |
}); |
|
990 |
checkWMTE(() -> { // > |
|
991 |
boolean r = vh.compareAndSet($value1$, $value1$, Void.class); |
|
992 |
}); |
|
993 |
||
994 |
||
995 |
// WeakCompareAndSet |
|
996 |
// Incorrect argument types |
|
997 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
998 |
boolean r = vh.weakCompareAndSet(Void.class, $value1$); |
|
999 |
}); |
|
1000 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1001 |
boolean r = vh.weakCompareAndSet($value1$, Void.class); |
|
1002 |
}); |
|
1003 |
// Incorrect arity |
|
1004 |
checkWMTE(() -> { // 0 |
|
1005 |
boolean r = vh.weakCompareAndSet(); |
|
1006 |
}); |
|
1007 |
checkWMTE(() -> { // > |
|
1008 |
boolean r = vh.weakCompareAndSet($value1$, $value1$, Void.class); |
|
1009 |
}); |
|
1010 |
||
1011 |
||
37719
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1012 |
// WeakCompareAndSetVolatile |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1013 |
// Incorrect argument types |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1014 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1015 |
boolean r = vh.weakCompareAndSetVolatile(Void.class, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1016 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1017 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1018 |
boolean r = vh.weakCompareAndSetVolatile($value1$, Void.class); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1019 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1020 |
// Incorrect arity |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1021 |
checkWMTE(() -> { // 0 |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1022 |
boolean r = vh.weakCompareAndSetVolatile(); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1023 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1024 |
checkWMTE(() -> { // > |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1025 |
boolean r = vh.weakCompareAndSetVolatile($value1$, $value1$, Void.class); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1026 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1027 |
|
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1028 |
|
36934 | 1029 |
// WeakCompareAndSetAcquire |
1030 |
// Incorrect argument types |
|
1031 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1032 |
boolean r = vh.weakCompareAndSetAcquire(Void.class, $value1$); |
|
1033 |
}); |
|
1034 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1035 |
boolean r = vh.weakCompareAndSetAcquire($value1$, Void.class); |
|
1036 |
}); |
|
1037 |
// Incorrect arity |
|
1038 |
checkWMTE(() -> { // 0 |
|
1039 |
boolean r = vh.weakCompareAndSetAcquire(); |
|
1040 |
}); |
|
1041 |
checkWMTE(() -> { // > |
|
1042 |
boolean r = vh.weakCompareAndSetAcquire($value1$, $value1$, Void.class); |
|
1043 |
}); |
|
1044 |
||
1045 |
||
1046 |
// WeakCompareAndSetRelease |
|
1047 |
// Incorrect argument types |
|
1048 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1049 |
boolean r = vh.weakCompareAndSetRelease(Void.class, $value1$); |
|
1050 |
}); |
|
1051 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1052 |
boolean r = vh.weakCompareAndSetRelease($value1$, Void.class); |
|
1053 |
}); |
|
1054 |
// Incorrect arity |
|
1055 |
checkWMTE(() -> { // 0 |
|
1056 |
boolean r = vh.weakCompareAndSetRelease(); |
|
1057 |
}); |
|
1058 |
checkWMTE(() -> { // > |
|
1059 |
boolean r = vh.weakCompareAndSetRelease($value1$, $value1$, Void.class); |
|
1060 |
}); |
|
1061 |
||
1062 |
||
1063 |
// CompareAndExchangeVolatile |
|
1064 |
// Incorrect argument types |
|
1065 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1066 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(Void.class, $value1$); |
|
1067 |
}); |
|
1068 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1069 |
$type$ x = ($type$) vh.compareAndExchangeVolatile($value1$, Void.class); |
|
1070 |
}); |
|
1071 |
// Incorrect return type |
|
1072 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1073 |
Void r = (Void) vh.compareAndExchangeVolatile($value1$, $value1$); |
|
1074 |
}); |
|
1075 |
checkWMTE(() -> { // primitive class |
|
1076 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.compareAndExchangeVolatile($value1$, $value1$); |
|
1077 |
}); |
|
1078 |
// Incorrect arity |
|
1079 |
checkWMTE(() -> { // 0 |
|
1080 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(); |
|
1081 |
}); |
|
1082 |
checkWMTE(() -> { // > |
|
1083 |
$type$ x = ($type$) vh.compareAndExchangeVolatile($value1$, $value1$, Void.class); |
|
1084 |
}); |
|
1085 |
||
1086 |
||
1087 |
// CompareAndExchangeAcquire |
|
1088 |
// Incorrect argument types |
|
1089 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1090 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(Void.class, $value1$); |
|
1091 |
}); |
|
1092 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1093 |
$type$ x = ($type$) vh.compareAndExchangeAcquire($value1$, Void.class); |
|
1094 |
}); |
|
1095 |
// Incorrect return type |
|
1096 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1097 |
Void r = (Void) vh.compareAndExchangeAcquire($value1$, $value1$); |
|
1098 |
}); |
|
1099 |
checkWMTE(() -> { // primitive class |
|
1100 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.compareAndExchangeAcquire($value1$, $value1$); |
|
1101 |
}); |
|
1102 |
// Incorrect arity |
|
1103 |
checkWMTE(() -> { // 0 |
|
1104 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(); |
|
1105 |
}); |
|
1106 |
checkWMTE(() -> { // > |
|
1107 |
$type$ x = ($type$) vh.compareAndExchangeAcquire($value1$, $value1$, Void.class); |
|
1108 |
}); |
|
1109 |
||
1110 |
||
1111 |
// CompareAndExchangeRelease |
|
1112 |
// Incorrect argument types |
|
1113 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1114 |
$type$ x = ($type$) vh.compareAndExchangeRelease(Void.class, $value1$); |
|
1115 |
}); |
|
1116 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1117 |
$type$ x = ($type$) vh.compareAndExchangeRelease($value1$, Void.class); |
|
1118 |
}); |
|
1119 |
// Incorrect return type |
|
1120 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1121 |
Void r = (Void) vh.compareAndExchangeRelease($value1$, $value1$); |
|
1122 |
}); |
|
1123 |
checkWMTE(() -> { // primitive class |
|
1124 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.compareAndExchangeRelease($value1$, $value1$); |
|
1125 |
}); |
|
1126 |
// Incorrect arity |
|
1127 |
checkWMTE(() -> { // 0 |
|
1128 |
$type$ x = ($type$) vh.compareAndExchangeRelease(); |
|
1129 |
}); |
|
1130 |
checkWMTE(() -> { // > |
|
1131 |
$type$ x = ($type$) vh.compareAndExchangeRelease($value1$, $value1$, Void.class); |
|
1132 |
}); |
|
1133 |
||
1134 |
||
1135 |
// GetAndSet |
|
1136 |
// Incorrect argument types |
|
1137 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1138 |
$type$ x = ($type$) vh.getAndSet(Void.class); |
|
1139 |
}); |
|
1140 |
// Incorrect return type |
|
1141 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1142 |
Void r = (Void) vh.getAndSet($value1$); |
|
1143 |
}); |
|
1144 |
checkWMTE(() -> { // primitive class |
|
1145 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSet($value1$); |
|
1146 |
}); |
|
1147 |
// Incorrect arity |
|
1148 |
checkWMTE(() -> { // 0 |
|
1149 |
$type$ x = ($type$) vh.getAndSet(); |
|
1150 |
}); |
|
1151 |
checkWMTE(() -> { // > |
|
1152 |
$type$ x = ($type$) vh.getAndSet($value1$, Void.class); |
|
1153 |
}); |
|
1154 |
#end[CAS] |
|
1155 |
||
1156 |
#if[AtomicAdd] |
|
1157 |
// GetAndAdd |
|
1158 |
// Incorrect argument types |
|
1159 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1160 |
$type$ x = ($type$) vh.getAndAdd(Void.class); |
|
1161 |
}); |
|
1162 |
// Incorrect return type |
|
1163 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1164 |
Void r = (Void) vh.getAndAdd($value1$); |
|
1165 |
}); |
|
1166 |
checkWMTE(() -> { // primitive class |
|
1167 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAdd($value1$); |
|
1168 |
}); |
|
1169 |
// Incorrect arity |
|
1170 |
checkWMTE(() -> { // 0 |
|
1171 |
$type$ x = ($type$) vh.getAndAdd(); |
|
1172 |
}); |
|
1173 |
checkWMTE(() -> { // > |
|
1174 |
$type$ x = ($type$) vh.getAndAdd($value1$, Void.class); |
|
1175 |
}); |
|
1176 |
||
1177 |
||
1178 |
// AddAndGet |
|
1179 |
// Incorrect argument types |
|
1180 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1181 |
$type$ x = ($type$) vh.addAndGet(Void.class); |
|
1182 |
}); |
|
1183 |
// Incorrect return type |
|
1184 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1185 |
Void r = (Void) vh.addAndGet($value1$); |
|
1186 |
}); |
|
1187 |
checkWMTE(() -> { // primitive class |
|
1188 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.addAndGet($value1$); |
|
1189 |
}); |
|
1190 |
// Incorrect arity |
|
1191 |
checkWMTE(() -> { // 0 |
|
1192 |
$type$ x = ($type$) vh.addAndGet(); |
|
1193 |
}); |
|
1194 |
checkWMTE(() -> { // > |
|
1195 |
$type$ x = ($type$) vh.addAndGet($value1$, Void.class); |
|
1196 |
}); |
|
1197 |
#end[AtomicAdd] |
|
1198 |
} |
|
1199 |
||
1200 |
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { |
|
1201 |
int i = 0; |
|
1202 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1203 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { |
36934 | 1204 |
// Incorrect return type |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1205 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 1206 |
Void x = (Void) hs.get(am, methodType(Void.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1207 |
invokeExact(); |
36934 | 1208 |
}); |
1209 |
checkWMTE(() -> { // primitive class |
|
1210 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1211 |
invokeExact(); |
36934 | 1212 |
}); |
1213 |
// Incorrect arity |
|
1214 |
checkWMTE(() -> { // > |
|
1215 |
$type$ x = ($type$) hs.get(am, methodType(Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1216 |
invokeExact(Void.class); |
36934 | 1217 |
}); |
1218 |
} |
|
1219 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1220 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1221 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class |
36934 | 1222 |
hs.get(am, methodType(void.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1223 |
invokeExact(Void.class); |
36934 | 1224 |
}); |
1225 |
// Incorrect arity |
|
1226 |
checkWMTE(() -> { // 0 |
|
1227 |
hs.get(am, methodType(void.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1228 |
invokeExact(); |
36934 | 1229 |
}); |
1230 |
checkWMTE(() -> { // > |
|
1231 |
hs.get(am, methodType(void.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1232 |
invokeExact($value1$, Void.class); |
36934 | 1233 |
}); |
1234 |
} |
|
1235 |
#if[CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1236 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { |
36934 | 1237 |
// Incorrect argument types |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1238 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class |
36934 | 1239 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1240 |
invokeExact(Void.class, $value1$); |
36934 | 1241 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1242 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class |
36934 | 1243 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1244 |
invokeExact($value1$, Void.class); |
36934 | 1245 |
}); |
1246 |
// Incorrect arity |
|
1247 |
checkWMTE(() -> { // 0 |
|
1248 |
boolean r = (boolean) hs.get(am, methodType(boolean.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1249 |
invokeExact(); |
36934 | 1250 |
}); |
1251 |
checkWMTE(() -> { // > |
|
1252 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1253 |
invokeExact($value1$, $value1$, Void.class); |
36934 | 1254 |
}); |
1255 |
} |
|
1256 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1257 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { |
36934 | 1258 |
// Incorrect argument types |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1259 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class |
36934 | 1260 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1261 |
invokeExact(Void.class, $value1$); |
36934 | 1262 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1263 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class |
36934 | 1264 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1265 |
invokeExact($value1$, Void.class); |
36934 | 1266 |
}); |
1267 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1268 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 1269 |
Void r = (Void) hs.get(am, methodType(Void.class, $type$.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1270 |
invokeExact($value1$, $value1$); |
36934 | 1271 |
}); |
1272 |
checkWMTE(() -> { // primitive class |
|
1273 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1274 |
invokeExact($value1$, $value1$); |
36934 | 1275 |
}); |
1276 |
// Incorrect arity |
|
1277 |
checkWMTE(() -> { // 0 |
|
1278 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1279 |
invokeExact(); |
36934 | 1280 |
}); |
1281 |
checkWMTE(() -> { // > |
|
1282 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1283 |
invokeExact($value1$, $value1$, Void.class); |
36934 | 1284 |
}); |
1285 |
} |
|
1286 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1287 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { |
36934 | 1288 |
// Incorrect argument types |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1289 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class |
36934 | 1290 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1291 |
invokeExact(Void.class); |
36934 | 1292 |
}); |
1293 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1294 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 1295 |
Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1296 |
invokeExact($value1$); |
36934 | 1297 |
}); |
1298 |
checkWMTE(() -> { // primitive class |
|
1299 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1300 |
invokeExact($value1$); |
36934 | 1301 |
}); |
1302 |
// Incorrect arity |
|
1303 |
checkWMTE(() -> { // 0 |
|
1304 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1305 |
invokeExact(); |
36934 | 1306 |
}); |
1307 |
checkWMTE(() -> { // > |
|
1308 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1309 |
invokeExact($value1$, Void.class); |
36934 | 1310 |
}); |
1311 |
} |
|
1312 |
#end[CAS] |
|
1313 |
||
1314 |
#if[AtomicAdd] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1315 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { |
36934 | 1316 |
// Incorrect argument types |
1317 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1318 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1319 |
invokeExact(Void.class); |
36934 | 1320 |
}); |
1321 |
// Incorrect return type |
|
1322 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1323 |
Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1324 |
invokeExact($value1$); |
36934 | 1325 |
}); |
1326 |
checkWMTE(() -> { // primitive class |
|
1327 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1328 |
invokeExact($value1$); |
36934 | 1329 |
}); |
1330 |
// Incorrect arity |
|
1331 |
checkWMTE(() -> { // 0 |
|
1332 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1333 |
invokeExact(); |
36934 | 1334 |
}); |
1335 |
checkWMTE(() -> { // > |
|
1336 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1337 |
invokeExact($value1$, Void.class); |
36934 | 1338 |
}); |
1339 |
} |
|
1340 |
#end[AtomicAdd] |
|
1341 |
} |
|
1342 |
||
1343 |
||
1344 |
static void testArrayWrongMethodType(VarHandle vh) throws Throwable { |
|
1345 |
$type$[] array = new $type$[10]; |
|
1346 |
Arrays.fill(array, $value1$); |
|
1347 |
||
1348 |
// Get |
|
1349 |
// Incorrect argument types |
|
1350 |
checkNPE(() -> { // null array |
|
1351 |
$type$ x = ($type$) vh.get(null, 0); |
|
1352 |
}); |
|
1353 |
checkCCE(() -> { // array reference class |
|
1354 |
$type$ x = ($type$) vh.get(Void.class, 0); |
|
1355 |
}); |
|
1356 |
checkWMTE(() -> { // array primitive class |
|
1357 |
$type$ x = ($type$) vh.get(0, 0); |
|
1358 |
}); |
|
1359 |
checkWMTE(() -> { // index reference class |
|
1360 |
$type$ x = ($type$) vh.get(array, Void.class); |
|
1361 |
}); |
|
1362 |
// Incorrect return type |
|
1363 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1364 |
Void x = (Void) vh.get(array, 0); |
|
1365 |
}); |
|
1366 |
checkWMTE(() -> { // primitive class |
|
1367 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.get(array, 0); |
|
1368 |
}); |
|
1369 |
// Incorrect arity |
|
1370 |
checkWMTE(() -> { // 0 |
|
1371 |
$type$ x = ($type$) vh.get(); |
|
1372 |
}); |
|
1373 |
checkWMTE(() -> { // > |
|
1374 |
$type$ x = ($type$) vh.get(array, 0, Void.class); |
|
1375 |
}); |
|
1376 |
||
1377 |
||
1378 |
// Set |
|
1379 |
// Incorrect argument types |
|
1380 |
checkNPE(() -> { // null array |
|
1381 |
vh.set(null, 0, $value1$); |
|
1382 |
}); |
|
1383 |
checkCCE(() -> { // array reference class |
|
1384 |
vh.set(Void.class, 0, $value1$); |
|
1385 |
}); |
|
1386 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1387 |
vh.set(array, 0, Void.class); |
|
1388 |
}); |
|
1389 |
checkWMTE(() -> { // receiver primitive class |
|
1390 |
vh.set(0, 0, $value1$); |
|
1391 |
}); |
|
1392 |
checkWMTE(() -> { // index reference class |
|
1393 |
vh.set(array, Void.class, $value1$); |
|
1394 |
}); |
|
1395 |
// Incorrect arity |
|
1396 |
checkWMTE(() -> { // 0 |
|
1397 |
vh.set(); |
|
1398 |
}); |
|
1399 |
checkWMTE(() -> { // > |
|
1400 |
vh.set(array, 0, $value1$, Void.class); |
|
1401 |
}); |
|
1402 |
||
1403 |
||
1404 |
// GetVolatile |
|
1405 |
// Incorrect argument types |
|
1406 |
checkNPE(() -> { // null array |
|
1407 |
$type$ x = ($type$) vh.getVolatile(null, 0); |
|
1408 |
}); |
|
1409 |
checkCCE(() -> { // array reference class |
|
1410 |
$type$ x = ($type$) vh.getVolatile(Void.class, 0); |
|
1411 |
}); |
|
1412 |
checkWMTE(() -> { // array primitive class |
|
1413 |
$type$ x = ($type$) vh.getVolatile(0, 0); |
|
1414 |
}); |
|
1415 |
checkWMTE(() -> { // index reference class |
|
1416 |
$type$ x = ($type$) vh.getVolatile(array, Void.class); |
|
1417 |
}); |
|
1418 |
// Incorrect return type |
|
1419 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1420 |
Void x = (Void) vh.getVolatile(array, 0); |
|
1421 |
}); |
|
1422 |
checkWMTE(() -> { // primitive class |
|
1423 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getVolatile(array, 0); |
|
1424 |
}); |
|
1425 |
// Incorrect arity |
|
1426 |
checkWMTE(() -> { // 0 |
|
1427 |
$type$ x = ($type$) vh.getVolatile(); |
|
1428 |
}); |
|
1429 |
checkWMTE(() -> { // > |
|
1430 |
$type$ x = ($type$) vh.getVolatile(array, 0, Void.class); |
|
1431 |
}); |
|
1432 |
||
1433 |
||
1434 |
// SetVolatile |
|
1435 |
// Incorrect argument types |
|
1436 |
checkNPE(() -> { // null array |
|
1437 |
vh.setVolatile(null, 0, $value1$); |
|
1438 |
}); |
|
1439 |
checkCCE(() -> { // array reference class |
|
1440 |
vh.setVolatile(Void.class, 0, $value1$); |
|
1441 |
}); |
|
1442 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1443 |
vh.setVolatile(array, 0, Void.class); |
|
1444 |
}); |
|
1445 |
checkWMTE(() -> { // receiver primitive class |
|
1446 |
vh.setVolatile(0, 0, $value1$); |
|
1447 |
}); |
|
1448 |
checkWMTE(() -> { // index reference class |
|
1449 |
vh.setVolatile(array, Void.class, $value1$); |
|
1450 |
}); |
|
1451 |
// Incorrect arity |
|
1452 |
checkWMTE(() -> { // 0 |
|
1453 |
vh.setVolatile(); |
|
1454 |
}); |
|
1455 |
checkWMTE(() -> { // > |
|
1456 |
vh.setVolatile(array, 0, $value1$, Void.class); |
|
1457 |
}); |
|
1458 |
||
1459 |
||
1460 |
// GetOpaque |
|
1461 |
// Incorrect argument types |
|
1462 |
checkNPE(() -> { // null array |
|
1463 |
$type$ x = ($type$) vh.getOpaque(null, 0); |
|
1464 |
}); |
|
1465 |
checkCCE(() -> { // array reference class |
|
1466 |
$type$ x = ($type$) vh.getOpaque(Void.class, 0); |
|
1467 |
}); |
|
1468 |
checkWMTE(() -> { // array primitive class |
|
1469 |
$type$ x = ($type$) vh.getOpaque(0, 0); |
|
1470 |
}); |
|
1471 |
checkWMTE(() -> { // index reference class |
|
1472 |
$type$ x = ($type$) vh.getOpaque(array, Void.class); |
|
1473 |
}); |
|
1474 |
// Incorrect return type |
|
1475 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1476 |
Void x = (Void) vh.getOpaque(array, 0); |
|
1477 |
}); |
|
1478 |
checkWMTE(() -> { // primitive class |
|
1479 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getOpaque(array, 0); |
|
1480 |
}); |
|
1481 |
// Incorrect arity |
|
1482 |
checkWMTE(() -> { // 0 |
|
1483 |
$type$ x = ($type$) vh.getOpaque(); |
|
1484 |
}); |
|
1485 |
checkWMTE(() -> { // > |
|
1486 |
$type$ x = ($type$) vh.getOpaque(array, 0, Void.class); |
|
1487 |
}); |
|
1488 |
||
1489 |
||
1490 |
// SetOpaque |
|
1491 |
// Incorrect argument types |
|
1492 |
checkNPE(() -> { // null array |
|
1493 |
vh.setOpaque(null, 0, $value1$); |
|
1494 |
}); |
|
1495 |
checkCCE(() -> { // array reference class |
|
1496 |
vh.setOpaque(Void.class, 0, $value1$); |
|
1497 |
}); |
|
1498 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1499 |
vh.setOpaque(array, 0, Void.class); |
|
1500 |
}); |
|
1501 |
checkWMTE(() -> { // receiver primitive class |
|
1502 |
vh.setOpaque(0, 0, $value1$); |
|
1503 |
}); |
|
1504 |
checkWMTE(() -> { // index reference class |
|
1505 |
vh.setOpaque(array, Void.class, $value1$); |
|
1506 |
}); |
|
1507 |
// Incorrect arity |
|
1508 |
checkWMTE(() -> { // 0 |
|
1509 |
vh.setOpaque(); |
|
1510 |
}); |
|
1511 |
checkWMTE(() -> { // > |
|
1512 |
vh.setOpaque(array, 0, $value1$, Void.class); |
|
1513 |
}); |
|
1514 |
||
1515 |
||
1516 |
// GetAcquire |
|
1517 |
// Incorrect argument types |
|
1518 |
checkNPE(() -> { // null array |
|
1519 |
$type$ x = ($type$) vh.getAcquire(null, 0); |
|
1520 |
}); |
|
1521 |
checkCCE(() -> { // array reference class |
|
1522 |
$type$ x = ($type$) vh.getAcquire(Void.class, 0); |
|
1523 |
}); |
|
1524 |
checkWMTE(() -> { // array primitive class |
|
1525 |
$type$ x = ($type$) vh.getAcquire(0, 0); |
|
1526 |
}); |
|
1527 |
checkWMTE(() -> { // index reference class |
|
1528 |
$type$ x = ($type$) vh.getAcquire(array, Void.class); |
|
1529 |
}); |
|
1530 |
// Incorrect return type |
|
1531 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1532 |
Void x = (Void) vh.getAcquire(array, 0); |
|
1533 |
}); |
|
1534 |
checkWMTE(() -> { // primitive class |
|
1535 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAcquire(array, 0); |
|
1536 |
}); |
|
1537 |
// Incorrect arity |
|
1538 |
checkWMTE(() -> { // 0 |
|
1539 |
$type$ x = ($type$) vh.getAcquire(); |
|
1540 |
}); |
|
1541 |
checkWMTE(() -> { // > |
|
1542 |
$type$ x = ($type$) vh.getAcquire(array, 0, Void.class); |
|
1543 |
}); |
|
1544 |
||
1545 |
||
1546 |
// SetRelease |
|
1547 |
// Incorrect argument types |
|
1548 |
checkNPE(() -> { // null array |
|
1549 |
vh.setRelease(null, 0, $value1$); |
|
1550 |
}); |
|
1551 |
checkCCE(() -> { // array reference class |
|
1552 |
vh.setRelease(Void.class, 0, $value1$); |
|
1553 |
}); |
|
1554 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1555 |
vh.setRelease(array, 0, Void.class); |
|
1556 |
}); |
|
1557 |
checkWMTE(() -> { // receiver primitive class |
|
1558 |
vh.setRelease(0, 0, $value1$); |
|
1559 |
}); |
|
1560 |
checkWMTE(() -> { // index reference class |
|
1561 |
vh.setRelease(array, Void.class, $value1$); |
|
1562 |
}); |
|
1563 |
// Incorrect arity |
|
1564 |
checkWMTE(() -> { // 0 |
|
1565 |
vh.setRelease(); |
|
1566 |
}); |
|
1567 |
checkWMTE(() -> { // > |
|
1568 |
vh.setRelease(array, 0, $value1$, Void.class); |
|
1569 |
}); |
|
1570 |
||
1571 |
||
1572 |
#if[CAS] |
|
1573 |
// CompareAndSet |
|
1574 |
// Incorrect argument types |
|
1575 |
checkNPE(() -> { // null receiver |
|
1576 |
boolean r = vh.compareAndSet(null, 0, $value1$, $value1$); |
|
1577 |
}); |
|
1578 |
checkCCE(() -> { // receiver reference class |
|
1579 |
boolean r = vh.compareAndSet(Void.class, 0, $value1$, $value1$); |
|
1580 |
}); |
|
1581 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1582 |
boolean r = vh.compareAndSet(array, 0, Void.class, $value1$); |
|
1583 |
}); |
|
1584 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1585 |
boolean r = vh.compareAndSet(array, 0, $value1$, Void.class); |
|
1586 |
}); |
|
1587 |
checkWMTE(() -> { // receiver primitive class |
|
1588 |
boolean r = vh.compareAndSet(0, 0, $value1$, $value1$); |
|
1589 |
}); |
|
1590 |
checkWMTE(() -> { // index reference class |
|
1591 |
boolean r = vh.compareAndSet(array, Void.class, $value1$, $value1$); |
|
1592 |
}); |
|
1593 |
// Incorrect arity |
|
1594 |
checkWMTE(() -> { // 0 |
|
1595 |
boolean r = vh.compareAndSet(); |
|
1596 |
}); |
|
1597 |
checkWMTE(() -> { // > |
|
1598 |
boolean r = vh.compareAndSet(array, 0, $value1$, $value1$, Void.class); |
|
1599 |
}); |
|
1600 |
||
1601 |
||
1602 |
// WeakCompareAndSet |
|
1603 |
// Incorrect argument types |
|
1604 |
checkNPE(() -> { // null receiver |
|
1605 |
boolean r = vh.weakCompareAndSet(null, 0, $value1$, $value1$); |
|
1606 |
}); |
|
1607 |
checkCCE(() -> { // receiver reference class |
|
1608 |
boolean r = vh.weakCompareAndSet(Void.class, 0, $value1$, $value1$); |
|
1609 |
}); |
|
1610 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1611 |
boolean r = vh.weakCompareAndSet(array, 0, Void.class, $value1$); |
|
1612 |
}); |
|
1613 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1614 |
boolean r = vh.weakCompareAndSet(array, 0, $value1$, Void.class); |
|
1615 |
}); |
|
1616 |
checkWMTE(() -> { // receiver primitive class |
|
1617 |
boolean r = vh.weakCompareAndSet(0, 0, $value1$, $value1$); |
|
1618 |
}); |
|
1619 |
checkWMTE(() -> { // index reference class |
|
1620 |
boolean r = vh.weakCompareAndSet(array, Void.class, $value1$, $value1$); |
|
1621 |
}); |
|
1622 |
// Incorrect arity |
|
1623 |
checkWMTE(() -> { // 0 |
|
1624 |
boolean r = vh.weakCompareAndSet(); |
|
1625 |
}); |
|
1626 |
checkWMTE(() -> { // > |
|
1627 |
boolean r = vh.weakCompareAndSet(array, 0, $value1$, $value1$, Void.class); |
|
1628 |
}); |
|
1629 |
||
1630 |
||
37719
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1631 |
// WeakCompareAndSetVolatile |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1632 |
// Incorrect argument types |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1633 |
checkNPE(() -> { // null receiver |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1634 |
boolean r = vh.weakCompareAndSetVolatile(null, 0, $value1$, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1635 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1636 |
checkCCE(() -> { // receiver reference class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1637 |
boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, $value1$, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1638 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1639 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1640 |
boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1641 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1642 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1643 |
boolean r = vh.weakCompareAndSetVolatile(array, 0, $value1$, Void.class); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1644 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1645 |
checkWMTE(() -> { // receiver primitive class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1646 |
boolean r = vh.weakCompareAndSetVolatile(0, 0, $value1$, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1647 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1648 |
checkWMTE(() -> { // index reference class |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1649 |
boolean r = vh.weakCompareAndSetVolatile(array, Void.class, $value1$, $value1$); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1650 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1651 |
// Incorrect arity |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1652 |
checkWMTE(() -> { // 0 |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1653 |
boolean r = vh.weakCompareAndSetVolatile(); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1654 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1655 |
checkWMTE(() -> { // > |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1656 |
boolean r = vh.weakCompareAndSetVolatile(array, 0, $value1$, $value1$, Void.class); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1657 |
}); |
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1658 |
|
add11bc0e6e2
8154755: Add a VarHandle weakCompareAndSet with volatile semantics
psandoz
parents:
37343
diff
changeset
|
1659 |
|
36934 | 1660 |
// WeakCompareAndSetAcquire |
1661 |
// Incorrect argument types |
|
1662 |
checkNPE(() -> { // null receiver |
|
1663 |
boolean r = vh.weakCompareAndSetAcquire(null, 0, $value1$, $value1$); |
|
1664 |
}); |
|
1665 |
checkCCE(() -> { // receiver reference class |
|
1666 |
boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, $value1$, $value1$); |
|
1667 |
}); |
|
1668 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1669 |
boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, $value1$); |
|
1670 |
}); |
|
1671 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1672 |
boolean r = vh.weakCompareAndSetAcquire(array, 0, $value1$, Void.class); |
|
1673 |
}); |
|
1674 |
checkWMTE(() -> { // receiver primitive class |
|
1675 |
boolean r = vh.weakCompareAndSetAcquire(0, 0, $value1$, $value1$); |
|
1676 |
}); |
|
1677 |
checkWMTE(() -> { // index reference class |
|
1678 |
boolean r = vh.weakCompareAndSetAcquire(array, Void.class, $value1$, $value1$); |
|
1679 |
}); |
|
1680 |
// Incorrect arity |
|
1681 |
checkWMTE(() -> { // 0 |
|
1682 |
boolean r = vh.weakCompareAndSetAcquire(); |
|
1683 |
}); |
|
1684 |
checkWMTE(() -> { // > |
|
1685 |
boolean r = vh.weakCompareAndSetAcquire(array, 0, $value1$, $value1$, Void.class); |
|
1686 |
}); |
|
1687 |
||
1688 |
||
1689 |
// WeakCompareAndSetRelease |
|
1690 |
// Incorrect argument types |
|
1691 |
checkNPE(() -> { // null receiver |
|
1692 |
boolean r = vh.weakCompareAndSetRelease(null, 0, $value1$, $value1$); |
|
1693 |
}); |
|
1694 |
checkCCE(() -> { // receiver reference class |
|
1695 |
boolean r = vh.weakCompareAndSetRelease(Void.class, 0, $value1$, $value1$); |
|
1696 |
}); |
|
1697 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1698 |
boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, $value1$); |
|
1699 |
}); |
|
1700 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1701 |
boolean r = vh.weakCompareAndSetRelease(array, 0, $value1$, Void.class); |
|
1702 |
}); |
|
1703 |
checkWMTE(() -> { // receiver primitive class |
|
1704 |
boolean r = vh.weakCompareAndSetRelease(0, 0, $value1$, $value1$); |
|
1705 |
}); |
|
1706 |
checkWMTE(() -> { // index reference class |
|
1707 |
boolean r = vh.weakCompareAndSetRelease(array, Void.class, $value1$, $value1$); |
|
1708 |
}); |
|
1709 |
// Incorrect arity |
|
1710 |
checkWMTE(() -> { // 0 |
|
1711 |
boolean r = vh.weakCompareAndSetRelease(); |
|
1712 |
}); |
|
1713 |
checkWMTE(() -> { // > |
|
1714 |
boolean r = vh.weakCompareAndSetRelease(array, 0, $value1$, $value1$, Void.class); |
|
1715 |
}); |
|
1716 |
||
1717 |
||
1718 |
// CompareAndExchangeVolatile |
|
1719 |
// Incorrect argument types |
|
1720 |
checkNPE(() -> { // null receiver |
|
1721 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(null, 0, $value1$, $value1$); |
|
1722 |
}); |
|
1723 |
checkCCE(() -> { // array reference class |
|
1724 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(Void.class, 0, $value1$, $value1$); |
|
1725 |
}); |
|
1726 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1727 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(array, 0, Void.class, $value1$); |
|
1728 |
}); |
|
1729 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1730 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(array, 0, $value1$, Void.class); |
|
1731 |
}); |
|
1732 |
checkWMTE(() -> { // array primitive class |
|
1733 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(0, 0, $value1$, $value1$); |
|
1734 |
}); |
|
1735 |
checkWMTE(() -> { // index reference class |
|
1736 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(array, Void.class, $value1$, $value1$); |
|
1737 |
}); |
|
1738 |
// Incorrect return type |
|
1739 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1740 |
Void r = (Void) vh.compareAndExchangeVolatile(array, 0, $value1$, $value1$); |
|
1741 |
}); |
|
1742 |
checkWMTE(() -> { // primitive class |
|
1743 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.compareAndExchangeVolatile(array, 0, $value1$, $value1$); |
|
1744 |
}); |
|
1745 |
// Incorrect arity |
|
1746 |
checkWMTE(() -> { // 0 |
|
1747 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(); |
|
1748 |
}); |
|
1749 |
checkWMTE(() -> { // > |
|
1750 |
$type$ x = ($type$) vh.compareAndExchangeVolatile(array, 0, $value1$, $value1$, Void.class); |
|
1751 |
}); |
|
1752 |
||
1753 |
||
1754 |
// CompareAndExchangeAcquire |
|
1755 |
// Incorrect argument types |
|
1756 |
checkNPE(() -> { // null receiver |
|
1757 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(null, 0, $value1$, $value1$); |
|
1758 |
}); |
|
1759 |
checkCCE(() -> { // array reference class |
|
1760 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(Void.class, 0, $value1$, $value1$); |
|
1761 |
}); |
|
1762 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1763 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(array, 0, Void.class, $value1$); |
|
1764 |
}); |
|
1765 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1766 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(array, 0, $value1$, Void.class); |
|
1767 |
}); |
|
1768 |
checkWMTE(() -> { // array primitive class |
|
1769 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(0, 0, $value1$, $value1$); |
|
1770 |
}); |
|
1771 |
checkWMTE(() -> { // index reference class |
|
1772 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(array, Void.class, $value1$, $value1$); |
|
1773 |
}); |
|
1774 |
// Incorrect return type |
|
1775 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1776 |
Void r = (Void) vh.compareAndExchangeAcquire(array, 0, $value1$, $value1$); |
|
1777 |
}); |
|
1778 |
checkWMTE(() -> { // primitive class |
|
1779 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.compareAndExchangeAcquire(array, 0, $value1$, $value1$); |
|
1780 |
}); |
|
1781 |
// Incorrect arity |
|
1782 |
checkWMTE(() -> { // 0 |
|
1783 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(); |
|
1784 |
}); |
|
1785 |
checkWMTE(() -> { // > |
|
1786 |
$type$ x = ($type$) vh.compareAndExchangeAcquire(array, 0, $value1$, $value1$, Void.class); |
|
1787 |
}); |
|
1788 |
||
1789 |
||
1790 |
// CompareAndExchangeRelease |
|
1791 |
// Incorrect argument types |
|
1792 |
checkNPE(() -> { // null receiver |
|
1793 |
$type$ x = ($type$) vh.compareAndExchangeRelease(null, 0, $value1$, $value1$); |
|
1794 |
}); |
|
1795 |
checkCCE(() -> { // array reference class |
|
1796 |
$type$ x = ($type$) vh.compareAndExchangeRelease(Void.class, 0, $value1$, $value1$); |
|
1797 |
}); |
|
1798 |
check{#if[String]?CCE:WMTE}(() -> { // expected reference class |
|
1799 |
$type$ x = ($type$) vh.compareAndExchangeRelease(array, 0, Void.class, $value1$); |
|
1800 |
}); |
|
1801 |
check{#if[String]?CCE:WMTE}(() -> { // actual reference class |
|
1802 |
$type$ x = ($type$) vh.compareAndExchangeRelease(array, 0, $value1$, Void.class); |
|
1803 |
}); |
|
1804 |
checkWMTE(() -> { // array primitive class |
|
1805 |
$type$ x = ($type$) vh.compareAndExchangeRelease(0, 0, $value1$, $value1$); |
|
1806 |
}); |
|
1807 |
checkWMTE(() -> { // index reference class |
|
1808 |
$type$ x = ($type$) vh.compareAndExchangeRelease(array, Void.class, $value1$, $value1$); |
|
1809 |
}); |
|
1810 |
// Incorrect return type |
|
1811 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1812 |
Void r = (Void) vh.compareAndExchangeRelease(array, 0, $value1$, $value1$); |
|
1813 |
}); |
|
1814 |
checkWMTE(() -> { // primitive class |
|
1815 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.compareAndExchangeRelease(array, 0, $value1$, $value1$); |
|
1816 |
}); |
|
1817 |
// Incorrect arity |
|
1818 |
checkWMTE(() -> { // 0 |
|
1819 |
$type$ x = ($type$) vh.compareAndExchangeRelease(); |
|
1820 |
}); |
|
1821 |
checkWMTE(() -> { // > |
|
1822 |
$type$ x = ($type$) vh.compareAndExchangeRelease(array, 0, $value1$, $value1$, Void.class); |
|
1823 |
}); |
|
1824 |
||
1825 |
||
1826 |
// GetAndSet |
|
1827 |
// Incorrect argument types |
|
1828 |
checkNPE(() -> { // null array |
|
1829 |
$type$ x = ($type$) vh.getAndSet(null, 0, $value1$); |
|
1830 |
}); |
|
1831 |
checkCCE(() -> { // array reference class |
|
1832 |
$type$ x = ($type$) vh.getAndSet(Void.class, 0, $value1$); |
|
1833 |
}); |
|
1834 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1835 |
$type$ x = ($type$) vh.getAndSet(array, 0, Void.class); |
|
1836 |
}); |
|
1837 |
checkWMTE(() -> { // reciarrayever primitive class |
|
1838 |
$type$ x = ($type$) vh.getAndSet(0, 0, $value1$); |
|
1839 |
}); |
|
1840 |
checkWMTE(() -> { // index reference class |
|
1841 |
$type$ x = ($type$) vh.getAndSet(array, Void.class, $value1$); |
|
1842 |
}); |
|
1843 |
// Incorrect return type |
|
1844 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1845 |
Void r = (Void) vh.getAndSet(array, 0, $value1$); |
|
1846 |
}); |
|
1847 |
checkWMTE(() -> { // primitive class |
|
1848 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSet(array, 0, $value1$); |
|
1849 |
}); |
|
1850 |
// Incorrect arity |
|
1851 |
checkWMTE(() -> { // 0 |
|
1852 |
$type$ x = ($type$) vh.getAndSet(); |
|
1853 |
}); |
|
1854 |
checkWMTE(() -> { // > |
|
1855 |
$type$ x = ($type$) vh.getAndSet(array, 0, $value1$, Void.class); |
|
1856 |
}); |
|
1857 |
#end[CAS] |
|
1858 |
||
1859 |
#if[AtomicAdd] |
|
1860 |
// GetAndAdd |
|
1861 |
// Incorrect argument types |
|
1862 |
checkNPE(() -> { // null array |
|
1863 |
$type$ x = ($type$) vh.getAndAdd(null, 0, $value1$); |
|
1864 |
}); |
|
1865 |
checkCCE(() -> { // array reference class |
|
1866 |
$type$ x = ($type$) vh.getAndAdd(Void.class, 0, $value1$); |
|
1867 |
}); |
|
1868 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1869 |
$type$ x = ($type$) vh.getAndAdd(array, 0, Void.class); |
|
1870 |
}); |
|
1871 |
checkWMTE(() -> { // array primitive class |
|
1872 |
$type$ x = ($type$) vh.getAndAdd(0, 0, $value1$); |
|
1873 |
}); |
|
1874 |
checkWMTE(() -> { // index reference class |
|
1875 |
$type$ x = ($type$) vh.getAndAdd(array, Void.class, $value1$); |
|
1876 |
}); |
|
1877 |
// Incorrect return type |
|
1878 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1879 |
Void r = (Void) vh.getAndAdd(array, 0, $value1$); |
|
1880 |
}); |
|
1881 |
checkWMTE(() -> { // primitive class |
|
1882 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAdd(array, 0, $value1$); |
|
1883 |
}); |
|
1884 |
// Incorrect arity |
|
1885 |
checkWMTE(() -> { // 0 |
|
1886 |
$type$ x = ($type$) vh.getAndAdd(); |
|
1887 |
}); |
|
1888 |
checkWMTE(() -> { // > |
|
1889 |
$type$ x = ($type$) vh.getAndAdd(array, 0, $value1$, Void.class); |
|
1890 |
}); |
|
1891 |
||
1892 |
||
1893 |
// AddAndGet |
|
1894 |
// Incorrect argument types |
|
1895 |
checkNPE(() -> { // null array |
|
1896 |
$type$ x = ($type$) vh.addAndGet(null, 0, $value1$); |
|
1897 |
}); |
|
1898 |
checkCCE(() -> { // array reference class |
|
1899 |
$type$ x = ($type$) vh.addAndGet(Void.class, 0, $value1$); |
|
1900 |
}); |
|
1901 |
check{#if[String]?CCE:WMTE}(() -> { // value reference class |
|
1902 |
$type$ x = ($type$) vh.addAndGet(array, 0, Void.class); |
|
1903 |
}); |
|
1904 |
checkWMTE(() -> { // array primitive class |
|
1905 |
$type$ x = ($type$) vh.addAndGet(0, 0, $value1$); |
|
1906 |
}); |
|
1907 |
checkWMTE(() -> { // index reference class |
|
1908 |
$type$ x = ($type$) vh.addAndGet(array, Void.class, $value1$); |
|
1909 |
}); |
|
1910 |
// Incorrect return type |
|
1911 |
check{#if[String]?CCE:WMTE}(() -> { // reference class |
|
1912 |
Void r = (Void) vh.addAndGet(array, 0, $value1$); |
|
1913 |
}); |
|
1914 |
checkWMTE(() -> { // primitive class |
|
1915 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) vh.addAndGet(array, 0, $value1$); |
|
1916 |
}); |
|
1917 |
// Incorrect arity |
|
1918 |
checkWMTE(() -> { // 0 |
|
1919 |
$type$ x = ($type$) vh.addAndGet(); |
|
1920 |
}); |
|
1921 |
checkWMTE(() -> { // > |
|
1922 |
$type$ x = ($type$) vh.addAndGet(array, 0, $value1$, Void.class); |
|
1923 |
}); |
|
1924 |
#end[AtomicAdd] |
|
1925 |
} |
|
1926 |
||
1927 |
static void testArrayWrongMethodType(Handles hs) throws Throwable { |
|
1928 |
$type$[] array = new $type$[10]; |
|
1929 |
Arrays.fill(array, $value1$); |
|
1930 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1931 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { |
36934 | 1932 |
// Incorrect argument types |
1933 |
checkNPE(() -> { // null array |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1934 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1935 |
invokeExact(($type$[]) null, 0); |
36934 | 1936 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1937 |
hs.checkWMTEOrCCE(() -> { // array reference class |
36934 | 1938 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1939 |
invokeExact(Void.class, 0); |
36934 | 1940 |
}); |
1941 |
checkWMTE(() -> { // array primitive class |
|
1942 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1943 |
invokeExact(0, 0); |
36934 | 1944 |
}); |
1945 |
checkWMTE(() -> { // index reference class |
|
1946 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1947 |
invokeExact(array, Void.class); |
36934 | 1948 |
}); |
1949 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1950 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 1951 |
Void x = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1952 |
invokeExact(array, 0); |
36934 | 1953 |
}); |
1954 |
checkWMTE(() -> { // primitive class |
|
1955 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1956 |
invokeExact(array, 0); |
36934 | 1957 |
}); |
1958 |
// Incorrect arity |
|
1959 |
checkWMTE(() -> { // 0 |
|
1960 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1961 |
invokeExact(); |
36934 | 1962 |
}); |
1963 |
checkWMTE(() -> { // > |
|
1964 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1965 |
invokeExact(array, 0, Void.class); |
36934 | 1966 |
}); |
1967 |
} |
|
1968 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
1969 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { |
36934 | 1970 |
// Incorrect argument types |
1971 |
checkNPE(() -> { // null array |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1972 |
hs.get(am, methodType(void.class, $type$[].class, int.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1973 |
invokeExact(($type$[]) null, 0, $value1$); |
36934 | 1974 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1975 |
hs.checkWMTEOrCCE(() -> { // array reference class |
36934 | 1976 |
hs.get(am, methodType(void.class, Class.class, int.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1977 |
invokeExact(Void.class, 0, $value1$); |
36934 | 1978 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1979 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class |
36934 | 1980 |
hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1981 |
invokeExact(array, 0, Void.class); |
36934 | 1982 |
}); |
1983 |
checkWMTE(() -> { // receiver primitive class |
|
1984 |
hs.get(am, methodType(void.class, int.class, int.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1985 |
invokeExact(0, 0, $value1$); |
36934 | 1986 |
}); |
1987 |
checkWMTE(() -> { // index reference class |
|
1988 |
hs.get(am, methodType(void.class, $type$[].class, Class.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1989 |
invokeExact(array, Void.class, $value1$); |
36934 | 1990 |
}); |
1991 |
// Incorrect arity |
|
1992 |
checkWMTE(() -> { // 0 |
|
1993 |
hs.get(am, methodType(void.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1994 |
invokeExact(); |
36934 | 1995 |
}); |
1996 |
checkWMTE(() -> { // > |
|
1997 |
hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
1998 |
invokeExact(array, 0, $value1$, Void.class); |
36934 | 1999 |
}); |
2000 |
} |
|
2001 |
#if[CAS] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
2002 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { |
36934 | 2003 |
// Incorrect argument types |
2004 |
checkNPE(() -> { // null receiver |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2005 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2006 |
invokeExact(($type$[]) null, 0, $value1$, $value1$); |
36934 | 2007 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2008 |
hs.checkWMTEOrCCE(() -> { // receiver reference class |
36934 | 2009 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, $type$.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2010 |
invokeExact(Void.class, 0, $value1$, $value1$); |
36934 | 2011 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2012 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class |
36934 | 2013 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, Class.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2014 |
invokeExact(array, 0, Void.class, $value1$); |
36934 | 2015 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2016 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class |
36934 | 2017 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2018 |
invokeExact(array, 0, $value1$, Void.class); |
36934 | 2019 |
}); |
2020 |
checkWMTE(() -> { // receiver primitive class |
|
2021 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, $type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2022 |
invokeExact(0, 0, $value1$, $value1$); |
36934 | 2023 |
}); |
2024 |
checkWMTE(() -> { // index reference class |
|
2025 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, Class.class, $type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2026 |
invokeExact(array, Void.class, $value1$, $value1$); |
36934 | 2027 |
}); |
2028 |
// Incorrect arity |
|
2029 |
checkWMTE(() -> { // 0 |
|
2030 |
boolean r = (boolean) hs.get(am, methodType(boolean.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2031 |
invokeExact(); |
36934 | 2032 |
}); |
2033 |
checkWMTE(() -> { // > |
|
2034 |
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2035 |
invokeExact(array, 0, $value1$, $value1$, Void.class); |
36934 | 2036 |
}); |
2037 |
} |
|
2038 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
2039 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { |
36934 | 2040 |
// Incorrect argument types |
2041 |
checkNPE(() -> { // null receiver |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2042 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2043 |
invokeExact(($type$[]) null, 0, $value1$, $value1$); |
36934 | 2044 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2045 |
hs.checkWMTEOrCCE(() -> { // array reference class |
36934 | 2046 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2047 |
invokeExact(Void.class, 0, $value1$, $value1$); |
36934 | 2048 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2049 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class |
36934 | 2050 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2051 |
invokeExact(array, 0, Void.class, $value1$); |
36934 | 2052 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2053 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class |
36934 | 2054 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2055 |
invokeExact(array, 0, $value1$, Void.class); |
36934 | 2056 |
}); |
2057 |
checkWMTE(() -> { // array primitive class |
|
2058 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2059 |
invokeExact(0, 0, $value1$, $value1$); |
36934 | 2060 |
}); |
2061 |
checkWMTE(() -> { // index reference class |
|
2062 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2063 |
invokeExact(array, Void.class, $value1$, $value1$); |
36934 | 2064 |
}); |
2065 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2066 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 2067 |
Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2068 |
invokeExact(array, 0, $value1$, $value1$); |
36934 | 2069 |
}); |
2070 |
checkWMTE(() -> { // primitive class |
|
2071 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2072 |
invokeExact(array, 0, $value1$, $value1$); |
36934 | 2073 |
}); |
2074 |
// Incorrect arity |
|
2075 |
checkWMTE(() -> { // 0 |
|
2076 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2077 |
invokeExact(); |
36934 | 2078 |
}); |
2079 |
checkWMTE(() -> { // > |
|
2080 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2081 |
invokeExact(array, 0, $value1$, $value1$, Void.class); |
36934 | 2082 |
}); |
2083 |
} |
|
2084 |
||
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
2085 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { |
36934 | 2086 |
// Incorrect argument types |
2087 |
checkNPE(() -> { // null array |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2088 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2089 |
invokeExact(($type$[]) null, 0, $value1$); |
36934 | 2090 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2091 |
hs.checkWMTEOrCCE(() -> { // array reference class |
36934 | 2092 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2093 |
invokeExact(Void.class, 0, $value1$); |
36934 | 2094 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2095 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class |
36934 | 2096 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2097 |
invokeExact(array, 0, Void.class); |
36934 | 2098 |
}); |
2099 |
checkWMTE(() -> { // array primitive class |
|
2100 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2101 |
invokeExact(0, 0, $value1$); |
36934 | 2102 |
}); |
2103 |
checkWMTE(() -> { // index reference class |
|
2104 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2105 |
invokeExact(array, Void.class, $value1$); |
36934 | 2106 |
}); |
2107 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2108 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 2109 |
Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2110 |
invokeExact(array, 0, $value1$); |
36934 | 2111 |
}); |
2112 |
checkWMTE(() -> { // primitive class |
|
2113 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2114 |
invokeExact(array, 0, $value1$); |
36934 | 2115 |
}); |
2116 |
// Incorrect arity |
|
2117 |
checkWMTE(() -> { // 0 |
|
2118 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2119 |
invokeExact(); |
36934 | 2120 |
}); |
2121 |
checkWMTE(() -> { // > |
|
2122 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2123 |
invokeExact(array, 0, $value1$, Void.class); |
36934 | 2124 |
}); |
2125 |
} |
|
2126 |
#end[CAS] |
|
2127 |
||
2128 |
#if[AtomicAdd] |
|
37343
35a2231828a7
8151705: VarHandle.AccessMode enum names should conform to code style
psandoz
parents:
36934
diff
changeset
|
2129 |
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { |
36934 | 2130 |
// Incorrect argument types |
2131 |
checkNPE(() -> { // null array |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2132 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)). |
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2133 |
invokeExact(($type$[]) null, 0, $value1$); |
36934 | 2134 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2135 |
hs.checkWMTEOrCCE(() -> { // array reference class |
36934 | 2136 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2137 |
invokeExact(Void.class, 0, $value1$); |
36934 | 2138 |
}); |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2139 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class |
36934 | 2140 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2141 |
invokeExact(array, 0, Void.class); |
36934 | 2142 |
}); |
2143 |
checkWMTE(() -> { // array primitive class |
|
2144 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2145 |
invokeExact(0, 0, $value1$); |
36934 | 2146 |
}); |
2147 |
checkWMTE(() -> { // index reference class |
|
2148 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2149 |
invokeExact(array, Void.class, $value1$); |
36934 | 2150 |
}); |
2151 |
// Incorrect return type |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2152 |
{#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class |
36934 | 2153 |
Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)). |
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2154 |
invokeExact(array, 0, $value1$); |
36934 | 2155 |
}); |
2156 |
checkWMTE(() -> { // primitive class |
|
2157 |
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2158 |
invokeExact(array, 0, $value1$); |
36934 | 2159 |
}); |
2160 |
// Incorrect arity |
|
2161 |
checkWMTE(() -> { // 0 |
|
2162 |
$type$ x = ($type$) hs.get(am, methodType($type$.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2163 |
invokeExact(); |
36934 | 2164 |
}); |
2165 |
checkWMTE(() -> { // > |
|
2166 |
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). |
|
38328
40435a469d25
8156485: MethodHandles.varHandleExactInvoker should perform exact checks
psandoz
parents:
37719
diff
changeset
|
2167 |
invokeExact(array, 0, $value1$, Void.class); |
36934 | 2168 |
}); |
2169 |
} |
|
2170 |
#end[AtomicAdd] |
|
2171 |
} |
|
2172 |
} |
|
2173 |