1 /*
2 * Copyright (c) 2015, 2025, 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
26 * @bug 8156486
27 * @run junit/othervm VarHandleTestMethodTypeInt
28 * @run junit/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=true -Djava.lang.invoke.VarHandle.VAR_HANDLE_IDENTITY_ADAPT=true VarHandleTestMethodTypeInt
29 * @run junit/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false -Djava.lang.invoke.VarHandle.VAR_HANDLE_IDENTITY_ADAPT=false VarHandleTestMethodTypeInt
30 * @run junit/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false -Djava.lang.invoke.VarHandle.VAR_HANDLE_IDENTITY_ADAPT=true VarHandleTestMethodTypeInt
31 */
32
33 import java.lang.invoke.MethodHandles;
34 import java.lang.invoke.VarHandle;
35 import java.util.ArrayList;
36 import java.util.Arrays;
37 import java.util.List;
38
39 import static java.lang.invoke.MethodType.*;
40
41 import org.junit.jupiter.api.BeforeAll;
42 import org.junit.jupiter.api.TestInstance;
43 import org.junit.jupiter.params.ParameterizedTest;
44 import org.junit.jupiter.params.provider.MethodSource;
45
46 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
47 public class VarHandleTestMethodTypeInt extends VarHandleBaseTest {
48 static final int static_final_v = 0x01234567;
49
50 static int static_v = 0x01234567;
51
52 final int final_v = 0x01234567;
53
54 int v = 0x01234567;
55
56 VarHandle vhFinalField;
57
58 VarHandle vhField;
59
60 VarHandle vhStaticField;
61
62 VarHandle vhStaticFinalField;
63
64 VarHandle vhArray;
65
66 @BeforeAll
67 public void setup() throws Exception {
68 vhFinalField = MethodHandles.lookup().findVarHandle(
69 VarHandleTestMethodTypeInt.class, "final_v", int.class);
70
71 vhField = MethodHandles.lookup().findVarHandle(
72 VarHandleTestMethodTypeInt.class, "v", int.class);
73
74 vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
75 VarHandleTestMethodTypeInt.class, "static_final_v", int.class);
76
77 vhStaticField = MethodHandles.lookup().findStaticVarHandle(
78 VarHandleTestMethodTypeInt.class, "static_v", int.class);
79
80 vhArray = MethodHandles.arrayElementVarHandle(int[].class);
81 }
82
83 public Object[][] accessTestCaseProvider() throws Exception {
84 List<AccessTestCase<?>> cases = new ArrayList<>();
85
86 cases.add(new VarHandleAccessTestCase("Instance field",
87 vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
88 false));
89
90 cases.add(new VarHandleAccessTestCase("Static field",
91 vhStaticField, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType,
92 false));
93
94 cases.add(new VarHandleAccessTestCase("Array",
95 vhArray, VarHandleTestMethodTypeInt::testArrayWrongMethodType,
96 false));
97
98 for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
99 cases.add(new MethodHandleAccessTestCase("Instance field",
100 vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
101 false));
102
103 cases.add(new MethodHandleAccessTestCase("Static field",
104 vhStaticField, f, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType,
105 false));
106
107 cases.add(new MethodHandleAccessTestCase("Array",
108 vhArray, f, VarHandleTestMethodTypeInt::testArrayWrongMethodType,
109 false));
110 }
111 // Work around issue with jtreg summary reporting which truncates
112 // the String result of Object.toString to 30 characters, hence
113 // the first dummy argument
114 return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new);
115 }
116
117 @ParameterizedTest
118 @MethodSource("accessTestCaseProvider")
119 public <T> void testAccess(String desc, AccessTestCase<T> atc) throws Throwable {
120 T t = atc.get();
121 int iters = atc.requiresLoop() ? ITERS : 1;
122 for (int c = 0; c < iters; c++) {
123 atc.testAccess(t);
124 }
125 }
126
127 static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeInt recv, VarHandle vh) throws Throwable {
128 // Get
129 // Incorrect argument types
130 checkNPE(() -> { // null receiver
131 int x = (int) vh.get(null);
132 });
133 checkCCE(() -> { // receiver reference class
134 int x = (int) vh.get(Void.class);
135 });
136 checkWMTE(() -> { // receiver primitive class
137 int x = (int) vh.get(0);
138 });
139 // Incorrect return type
140 checkWMTE(() -> { // reference class
141 Void x = (Void) vh.get(recv);
142 });
143 checkWMTE(() -> { // primitive class
144 boolean x = (boolean) vh.get(recv);
145 });
146 // Incorrect arity
147 checkWMTE(() -> { // 0
148 int x = (int) vh.get();
149 });
150 checkWMTE(() -> { // >
151 int x = (int) vh.get(recv, Void.class);
152 });
153
154
155 // Set
156 // Incorrect argument types
157 checkNPE(() -> { // null receiver
158 vh.set(null, 0x01234567);
159 });
160 checkCCE(() -> { // receiver reference class
161 vh.set(Void.class, 0x01234567);
162 });
163 checkWMTE(() -> { // value reference class
164 vh.set(recv, Void.class);
165 });
166 checkWMTE(() -> { // receiver primitive class
167 vh.set(0, 0x01234567);
168 });
169 // Incorrect arity
170 checkWMTE(() -> { // 0
171 vh.set();
172 });
173 checkWMTE(() -> { // >
174 vh.set(recv, 0x01234567, Void.class);
175 });
176
177
178 // GetVolatile
179 // Incorrect argument types
180 checkNPE(() -> { // null receiver
181 int x = (int) vh.getVolatile(null);
182 });
183 checkCCE(() -> { // receiver reference class
184 int x = (int) vh.getVolatile(Void.class);
185 });
186 checkWMTE(() -> { // receiver primitive class
187 int x = (int) vh.getVolatile(0);
188 });
189 // Incorrect return type
190 checkWMTE(() -> { // reference class
191 Void x = (Void) vh.getVolatile(recv);
192 });
193 checkWMTE(() -> { // primitive class
194 boolean x = (boolean) vh.getVolatile(recv);
195 });
196 // Incorrect arity
197 checkWMTE(() -> { // 0
198 int x = (int) vh.getVolatile();
199 });
200 checkWMTE(() -> { // >
201 int x = (int) vh.getVolatile(recv, Void.class);
202 });
203
204
205 // SetVolatile
206 // Incorrect argument types
207 checkNPE(() -> { // null receiver
208 vh.setVolatile(null, 0x01234567);
209 });
210 checkCCE(() -> { // receiver reference class
211 vh.setVolatile(Void.class, 0x01234567);
212 });
213 checkWMTE(() -> { // value reference class
214 vh.setVolatile(recv, Void.class);
215 });
216 checkWMTE(() -> { // receiver primitive class
217 vh.setVolatile(0, 0x01234567);
218 });
219 // Incorrect arity
220 checkWMTE(() -> { // 0
221 vh.setVolatile();
222 });
223 checkWMTE(() -> { // >
224 vh.setVolatile(recv, 0x01234567, Void.class);
225 });
226
227
228 // GetOpaque
229 // Incorrect argument types
230 checkNPE(() -> { // null receiver
231 int x = (int) vh.getOpaque(null);
232 });
233 checkCCE(() -> { // receiver reference class
234 int x = (int) vh.getOpaque(Void.class);
235 });
236 checkWMTE(() -> { // receiver primitive class
237 int x = (int) vh.getOpaque(0);
238 });
239 // Incorrect return type
240 checkWMTE(() -> { // reference class
241 Void x = (Void) vh.getOpaque(recv);
242 });
243 checkWMTE(() -> { // primitive class
244 boolean x = (boolean) vh.getOpaque(recv);
245 });
246 // Incorrect arity
247 checkWMTE(() -> { // 0
248 int x = (int) vh.getOpaque();
249 });
250 checkWMTE(() -> { // >
251 int x = (int) vh.getOpaque(recv, Void.class);
252 });
253
254
255 // SetOpaque
256 // Incorrect argument types
257 checkNPE(() -> { // null receiver
258 vh.setOpaque(null, 0x01234567);
259 });
260 checkCCE(() -> { // receiver reference class
261 vh.setOpaque(Void.class, 0x01234567);
262 });
263 checkWMTE(() -> { // value reference class
264 vh.setOpaque(recv, Void.class);
265 });
266 checkWMTE(() -> { // receiver primitive class
267 vh.setOpaque(0, 0x01234567);
268 });
269 // Incorrect arity
270 checkWMTE(() -> { // 0
271 vh.setOpaque();
272 });
273 checkWMTE(() -> { // >
274 vh.setOpaque(recv, 0x01234567, Void.class);
275 });
276
277
278 // GetAcquire
279 // Incorrect argument types
280 checkNPE(() -> { // null receiver
281 int x = (int) vh.getAcquire(null);
282 });
283 checkCCE(() -> { // receiver reference class
284 int x = (int) vh.getAcquire(Void.class);
285 });
286 checkWMTE(() -> { // receiver primitive class
287 int x = (int) vh.getAcquire(0);
288 });
289 // Incorrect return type
290 checkWMTE(() -> { // reference class
291 Void x = (Void) vh.getAcquire(recv);
292 });
293 checkWMTE(() -> { // primitive class
294 boolean x = (boolean) vh.getAcquire(recv);
295 });
296 // Incorrect arity
297 checkWMTE(() -> { // 0
298 int x = (int) vh.getAcquire();
299 });
300 checkWMTE(() -> { // >
301 int x = (int) vh.getAcquire(recv, Void.class);
302 });
303
304
305 // SetRelease
306 // Incorrect argument types
307 checkNPE(() -> { // null receiver
308 vh.setRelease(null, 0x01234567);
309 });
310 checkCCE(() -> { // receiver reference class
311 vh.setRelease(Void.class, 0x01234567);
312 });
313 checkWMTE(() -> { // value reference class
314 vh.setRelease(recv, Void.class);
315 });
316 checkWMTE(() -> { // receiver primitive class
317 vh.setRelease(0, 0x01234567);
318 });
319 // Incorrect arity
320 checkWMTE(() -> { // 0
321 vh.setRelease();
322 });
323 checkWMTE(() -> { // >
324 vh.setRelease(recv, 0x01234567, Void.class);
325 });
326
327
328 // CompareAndSet
329 // Incorrect argument types
330 checkNPE(() -> { // null receiver
331 boolean r = vh.compareAndSet(null, 0x01234567, 0x01234567);
332 });
333 checkCCE(() -> { // receiver reference class
334 boolean r = vh.compareAndSet(Void.class, 0x01234567, 0x01234567);
335 });
336 checkWMTE(() -> { // expected reference class
337 boolean r = vh.compareAndSet(recv, Void.class, 0x01234567);
338 });
339 checkWMTE(() -> { // actual reference class
340 boolean r = vh.compareAndSet(recv, 0x01234567, Void.class);
341 });
342 checkWMTE(() -> { // receiver primitive class
343 boolean r = vh.compareAndSet(0, 0x01234567, 0x01234567);
344 });
345 // Incorrect arity
346 checkWMTE(() -> { // 0
347 boolean r = vh.compareAndSet();
348 });
349 checkWMTE(() -> { // >
350 boolean r = vh.compareAndSet(recv, 0x01234567, 0x01234567, Void.class);
351 });
352
353
354 // WeakCompareAndSet
355 // Incorrect argument types
356 checkNPE(() -> { // null receiver
357 boolean r = vh.weakCompareAndSetPlain(null, 0x01234567, 0x01234567);
358 });
359 checkCCE(() -> { // receiver reference class
360 boolean r = vh.weakCompareAndSetPlain(Void.class, 0x01234567, 0x01234567);
361 });
362 checkWMTE(() -> { // expected reference class
363 boolean r = vh.weakCompareAndSetPlain(recv, Void.class, 0x01234567);
364 });
365 checkWMTE(() -> { // actual reference class
366 boolean r = vh.weakCompareAndSetPlain(recv, 0x01234567, Void.class);
367 });
368 checkWMTE(() -> { // receiver primitive class
369 boolean r = vh.weakCompareAndSetPlain(0, 0x01234567, 0x01234567);
370 });
371 // Incorrect arity
372 checkWMTE(() -> { // 0
373 boolean r = vh.weakCompareAndSetPlain();
374 });
375 checkWMTE(() -> { // >
376 boolean r = vh.weakCompareAndSetPlain(recv, 0x01234567, 0x01234567, Void.class);
377 });
378
379
380 // WeakCompareAndSetVolatile
381 // Incorrect argument types
382 checkNPE(() -> { // null receiver
383 boolean r = vh.weakCompareAndSet(null, 0x01234567, 0x01234567);
384 });
385 checkCCE(() -> { // receiver reference class
386 boolean r = vh.weakCompareAndSet(Void.class, 0x01234567, 0x01234567);
387 });
388 checkWMTE(() -> { // expected reference class
389 boolean r = vh.weakCompareAndSet(recv, Void.class, 0x01234567);
390 });
391 checkWMTE(() -> { // actual reference class
392 boolean r = vh.weakCompareAndSet(recv, 0x01234567, Void.class);
393 });
394 checkWMTE(() -> { // receiver primitive class
395 boolean r = vh.weakCompareAndSet(0, 0x01234567, 0x01234567);
396 });
397 // Incorrect arity
398 checkWMTE(() -> { // 0
399 boolean r = vh.weakCompareAndSet();
400 });
401 checkWMTE(() -> { // >
402 boolean r = vh.weakCompareAndSet(recv, 0x01234567, 0x01234567, Void.class);
403 });
404
405
406 // WeakCompareAndSetAcquire
407 // Incorrect argument types
408 checkNPE(() -> { // null receiver
409 boolean r = vh.weakCompareAndSetAcquire(null, 0x01234567, 0x01234567);
410 });
411 checkCCE(() -> { // receiver reference class
412 boolean r = vh.weakCompareAndSetAcquire(Void.class, 0x01234567, 0x01234567);
413 });
414 checkWMTE(() -> { // expected reference class
415 boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, 0x01234567);
416 });
417 checkWMTE(() -> { // actual reference class
418 boolean r = vh.weakCompareAndSetAcquire(recv, 0x01234567, Void.class);
419 });
420 checkWMTE(() -> { // receiver primitive class
421 boolean r = vh.weakCompareAndSetAcquire(0, 0x01234567, 0x01234567);
422 });
423 // Incorrect arity
424 checkWMTE(() -> { // 0
425 boolean r = vh.weakCompareAndSetAcquire();
426 });
427 checkWMTE(() -> { // >
428 boolean r = vh.weakCompareAndSetAcquire(recv, 0x01234567, 0x01234567, Void.class);
429 });
430
431
432 // WeakCompareAndSetRelease
433 // Incorrect argument types
434 checkNPE(() -> { // null receiver
435 boolean r = vh.weakCompareAndSetRelease(null, 0x01234567, 0x01234567);
436 });
437 checkCCE(() -> { // receiver reference class
438 boolean r = vh.weakCompareAndSetRelease(Void.class, 0x01234567, 0x01234567);
439 });
440 checkWMTE(() -> { // expected reference class
441 boolean r = vh.weakCompareAndSetRelease(recv, Void.class, 0x01234567);
442 });
443 checkWMTE(() -> { // actual reference class
444 boolean r = vh.weakCompareAndSetRelease(recv, 0x01234567, Void.class);
445 });
446 checkWMTE(() -> { // receiver primitive class
447 boolean r = vh.weakCompareAndSetRelease(0, 0x01234567, 0x01234567);
448 });
449 // Incorrect arity
450 checkWMTE(() -> { // 0
451 boolean r = vh.weakCompareAndSetRelease();
452 });
453 checkWMTE(() -> { // >
454 boolean r = vh.weakCompareAndSetRelease(recv, 0x01234567, 0x01234567, Void.class);
455 });
456
457
458 // CompareAndExchange
459 // Incorrect argument types
460 checkNPE(() -> { // null receiver
461 int x = (int) vh.compareAndExchange(null, 0x01234567, 0x01234567);
462 });
463 checkCCE(() -> { // receiver reference class
464 int x = (int) vh.compareAndExchange(Void.class, 0x01234567, 0x01234567);
465 });
466 checkWMTE(() -> { // expected reference class
467 int x = (int) vh.compareAndExchange(recv, Void.class, 0x01234567);
468 });
469 checkWMTE(() -> { // actual reference class
470 int x = (int) vh.compareAndExchange(recv, 0x01234567, Void.class);
471 });
472 checkWMTE(() -> { // reciever primitive class
473 int x = (int) vh.compareAndExchange(0, 0x01234567, 0x01234567);
474 });
475 // Incorrect return type
476 checkWMTE(() -> { // reference class
477 Void r = (Void) vh.compareAndExchange(recv, 0x01234567, 0x01234567);
478 });
479 checkWMTE(() -> { // primitive class
480 boolean x = (boolean) vh.compareAndExchange(recv, 0x01234567, 0x01234567);
481 });
482 // Incorrect arity
483 checkWMTE(() -> { // 0
484 int x = (int) vh.compareAndExchange();
485 });
486 checkWMTE(() -> { // >
487 int x = (int) vh.compareAndExchange(recv, 0x01234567, 0x01234567, Void.class);
488 });
489
490
491 // CompareAndExchangeAcquire
492 // Incorrect argument types
493 checkNPE(() -> { // null receiver
494 int x = (int) vh.compareAndExchangeAcquire(null, 0x01234567, 0x01234567);
495 });
496 checkCCE(() -> { // receiver reference class
497 int x = (int) vh.compareAndExchangeAcquire(Void.class, 0x01234567, 0x01234567);
498 });
499 checkWMTE(() -> { // expected reference class
500 int x = (int) vh.compareAndExchangeAcquire(recv, Void.class, 0x01234567);
501 });
502 checkWMTE(() -> { // actual reference class
503 int x = (int) vh.compareAndExchangeAcquire(recv, 0x01234567, Void.class);
504 });
505 checkWMTE(() -> { // reciever primitive class
506 int x = (int) vh.compareAndExchangeAcquire(0, 0x01234567, 0x01234567);
507 });
508 // Incorrect return type
509 checkWMTE(() -> { // reference class
510 Void r = (Void) vh.compareAndExchangeAcquire(recv, 0x01234567, 0x01234567);
511 });
512 checkWMTE(() -> { // primitive class
513 boolean x = (boolean) vh.compareAndExchangeAcquire(recv, 0x01234567, 0x01234567);
514 });
515 // Incorrect arity
516 checkWMTE(() -> { // 0
517 int x = (int) vh.compareAndExchangeAcquire();
518 });
519 checkWMTE(() -> { // >
520 int x = (int) vh.compareAndExchangeAcquire(recv, 0x01234567, 0x01234567, Void.class);
521 });
522
523
524 // CompareAndExchangeRelease
525 // Incorrect argument types
526 checkNPE(() -> { // null receiver
527 int x = (int) vh.compareAndExchangeRelease(null, 0x01234567, 0x01234567);
528 });
529 checkCCE(() -> { // receiver reference class
530 int x = (int) vh.compareAndExchangeRelease(Void.class, 0x01234567, 0x01234567);
531 });
532 checkWMTE(() -> { // expected reference class
533 int x = (int) vh.compareAndExchangeRelease(recv, Void.class, 0x01234567);
534 });
535 checkWMTE(() -> { // actual reference class
536 int x = (int) vh.compareAndExchangeRelease(recv, 0x01234567, Void.class);
537 });
538 checkWMTE(() -> { // reciever primitive class
539 int x = (int) vh.compareAndExchangeRelease(0, 0x01234567, 0x01234567);
540 });
541 // Incorrect return type
542 checkWMTE(() -> { // reference class
543 Void r = (Void) vh.compareAndExchangeRelease(recv, 0x01234567, 0x01234567);
544 });
545 checkWMTE(() -> { // primitive class
546 boolean x = (boolean) vh.compareAndExchangeRelease(recv, 0x01234567, 0x01234567);
547 });
548 // Incorrect arity
549 checkWMTE(() -> { // 0
550 int x = (int) vh.compareAndExchangeRelease();
551 });
552 checkWMTE(() -> { // >
553 int x = (int) vh.compareAndExchangeRelease(recv, 0x01234567, 0x01234567, Void.class);
554 });
555
556
557 // GetAndSet
558 // Incorrect argument types
559 checkNPE(() -> { // null receiver
560 int x = (int) vh.getAndSet(null, 0x01234567);
561 });
562 checkCCE(() -> { // receiver reference class
563 int x = (int) vh.getAndSet(Void.class, 0x01234567);
564 });
565 checkWMTE(() -> { // value reference class
566 int x = (int) vh.getAndSet(recv, Void.class);
567 });
568 checkWMTE(() -> { // reciever primitive class
569 int x = (int) vh.getAndSet(0, 0x01234567);
570 });
571 // Incorrect return type
572 checkWMTE(() -> { // reference class
573 Void r = (Void) vh.getAndSet(recv, 0x01234567);
574 });
575 checkWMTE(() -> { // primitive class
576 boolean x = (boolean) vh.getAndSet(recv, 0x01234567);
577 });
578 // Incorrect arity
579 checkWMTE(() -> { // 0
580 int x = (int) vh.getAndSet();
581 });
582 checkWMTE(() -> { // >
583 int x = (int) vh.getAndSet(recv, 0x01234567, Void.class);
584 });
585
586 // GetAndSetAcquire
587 // Incorrect argument types
588 checkNPE(() -> { // null receiver
589 int x = (int) vh.getAndSetAcquire(null, 0x01234567);
590 });
591 checkCCE(() -> { // receiver reference class
592 int x = (int) vh.getAndSetAcquire(Void.class, 0x01234567);
593 });
594 checkWMTE(() -> { // value reference class
595 int x = (int) vh.getAndSetAcquire(recv, Void.class);
596 });
597 checkWMTE(() -> { // reciever primitive class
598 int x = (int) vh.getAndSetAcquire(0, 0x01234567);
599 });
600 // Incorrect return type
601 checkWMTE(() -> { // reference class
602 Void r = (Void) vh.getAndSetAcquire(recv, 0x01234567);
603 });
604 checkWMTE(() -> { // primitive class
605 boolean x = (boolean) vh.getAndSetAcquire(recv, 0x01234567);
606 });
607 // Incorrect arity
608 checkWMTE(() -> { // 0
609 int x = (int) vh.getAndSetAcquire();
610 });
611 checkWMTE(() -> { // >
612 int x = (int) vh.getAndSetAcquire(recv, 0x01234567, Void.class);
613 });
614
615 // GetAndSetRelease
616 // Incorrect argument types
617 checkNPE(() -> { // null receiver
618 int x = (int) vh.getAndSetRelease(null, 0x01234567);
619 });
620 checkCCE(() -> { // receiver reference class
621 int x = (int) vh.getAndSetRelease(Void.class, 0x01234567);
622 });
623 checkWMTE(() -> { // value reference class
624 int x = (int) vh.getAndSetRelease(recv, Void.class);
625 });
626 checkWMTE(() -> { // reciever primitive class
627 int x = (int) vh.getAndSetRelease(0, 0x01234567);
628 });
629 // Incorrect return type
630 checkWMTE(() -> { // reference class
631 Void r = (Void) vh.getAndSetRelease(recv, 0x01234567);
632 });
633 checkWMTE(() -> { // primitive class
634 boolean x = (boolean) vh.getAndSetRelease(recv, 0x01234567);
635 });
636 // Incorrect arity
637 checkWMTE(() -> { // 0
638 int x = (int) vh.getAndSetRelease();
639 });
640 checkWMTE(() -> { // >
641 int x = (int) vh.getAndSetRelease(recv, 0x01234567, Void.class);
642 });
643
644 // GetAndAdd
645 // Incorrect argument types
646 checkNPE(() -> { // null receiver
647 int x = (int) vh.getAndAdd(null, 0x01234567);
648 });
649 checkCCE(() -> { // receiver reference class
650 int x = (int) vh.getAndAdd(Void.class, 0x01234567);
651 });
652 checkWMTE(() -> { // value reference class
653 int x = (int) vh.getAndAdd(recv, Void.class);
654 });
655 checkWMTE(() -> { // reciever primitive class
656 int x = (int) vh.getAndAdd(0, 0x01234567);
657 });
658 // Incorrect return type
659 checkWMTE(() -> { // reference class
660 Void r = (Void) vh.getAndAdd(recv, 0x01234567);
661 });
662 checkWMTE(() -> { // primitive class
663 boolean x = (boolean) vh.getAndAdd(recv, 0x01234567);
664 });
665 // Incorrect arity
666 checkWMTE(() -> { // 0
667 int x = (int) vh.getAndAdd();
668 });
669 checkWMTE(() -> { // >
670 int x = (int) vh.getAndAdd(recv, 0x01234567, Void.class);
671 });
672
673 // GetAndAddAcquire
674 // Incorrect argument types
675 checkNPE(() -> { // null receiver
676 int x = (int) vh.getAndAddAcquire(null, 0x01234567);
677 });
678 checkCCE(() -> { // receiver reference class
679 int x = (int) vh.getAndAddAcquire(Void.class, 0x01234567);
680 });
681 checkWMTE(() -> { // value reference class
682 int x = (int) vh.getAndAddAcquire(recv, Void.class);
683 });
684 checkWMTE(() -> { // reciever primitive class
685 int x = (int) vh.getAndAddAcquire(0, 0x01234567);
686 });
687 // Incorrect return type
688 checkWMTE(() -> { // reference class
689 Void r = (Void) vh.getAndAddAcquire(recv, 0x01234567);
690 });
691 checkWMTE(() -> { // primitive class
692 boolean x = (boolean) vh.getAndAddAcquire(recv, 0x01234567);
693 });
694 // Incorrect arity
695 checkWMTE(() -> { // 0
696 int x = (int) vh.getAndAddAcquire();
697 });
698 checkWMTE(() -> { // >
699 int x = (int) vh.getAndAddAcquire(recv, 0x01234567, Void.class);
700 });
701
702 // GetAndAddRelease
703 // Incorrect argument types
704 checkNPE(() -> { // null receiver
705 int x = (int) vh.getAndAddRelease(null, 0x01234567);
706 });
707 checkCCE(() -> { // receiver reference class
708 int x = (int) vh.getAndAddRelease(Void.class, 0x01234567);
709 });
710 checkWMTE(() -> { // value reference class
711 int x = (int) vh.getAndAddRelease(recv, Void.class);
712 });
713 checkWMTE(() -> { // reciever primitive class
714 int x = (int) vh.getAndAddRelease(0, 0x01234567);
715 });
716 // Incorrect return type
717 checkWMTE(() -> { // reference class
718 Void r = (Void) vh.getAndAddRelease(recv, 0x01234567);
719 });
720 checkWMTE(() -> { // primitive class
721 boolean x = (boolean) vh.getAndAddRelease(recv, 0x01234567);
722 });
723 // Incorrect arity
724 checkWMTE(() -> { // 0
725 int x = (int) vh.getAndAddRelease();
726 });
727 checkWMTE(() -> { // >
728 int x = (int) vh.getAndAddRelease(recv, 0x01234567, Void.class);
729 });
730
731 // GetAndBitwiseOr
732 // Incorrect argument types
733 checkNPE(() -> { // null receiver
734 int x = (int) vh.getAndBitwiseOr(null, 0x01234567);
735 });
736 checkCCE(() -> { // receiver reference class
737 int x = (int) vh.getAndBitwiseOr(Void.class, 0x01234567);
738 });
739 checkWMTE(() -> { // value reference class
740 int x = (int) vh.getAndBitwiseOr(recv, Void.class);
741 });
742 checkWMTE(() -> { // reciever primitive class
743 int x = (int) vh.getAndBitwiseOr(0, 0x01234567);
744 });
745 // Incorrect return type
746 checkWMTE(() -> { // reference class
747 Void r = (Void) vh.getAndBitwiseOr(recv, 0x01234567);
748 });
749 checkWMTE(() -> { // primitive class
750 boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x01234567);
751 });
752 // Incorrect arity
753 checkWMTE(() -> { // 0
754 int x = (int) vh.getAndBitwiseOr();
755 });
756 checkWMTE(() -> { // >
757 int x = (int) vh.getAndBitwiseOr(recv, 0x01234567, Void.class);
758 });
759
760
761 // GetAndBitwiseOrAcquire
762 // Incorrect argument types
763 checkNPE(() -> { // null receiver
764 int x = (int) vh.getAndBitwiseOrAcquire(null, 0x01234567);
765 });
766 checkCCE(() -> { // receiver reference class
767 int x = (int) vh.getAndBitwiseOrAcquire(Void.class, 0x01234567);
768 });
769 checkWMTE(() -> { // value reference class
770 int x = (int) vh.getAndBitwiseOrAcquire(recv, Void.class);
771 });
772 checkWMTE(() -> { // reciever primitive class
773 int x = (int) vh.getAndBitwiseOrAcquire(0, 0x01234567);
774 });
775 // Incorrect return type
776 checkWMTE(() -> { // reference class
777 Void r = (Void) vh.getAndBitwiseOrAcquire(recv, 0x01234567);
778 });
779 checkWMTE(() -> { // primitive class
780 boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, 0x01234567);
781 });
782 // Incorrect arity
783 checkWMTE(() -> { // 0
784 int x = (int) vh.getAndBitwiseOrAcquire();
785 });
786 checkWMTE(() -> { // >
787 int x = (int) vh.getAndBitwiseOrAcquire(recv, 0x01234567, Void.class);
788 });
789
790
791 // GetAndBitwiseOrRelease
792 // Incorrect argument types
793 checkNPE(() -> { // null receiver
794 int x = (int) vh.getAndBitwiseOrRelease(null, 0x01234567);
795 });
796 checkCCE(() -> { // receiver reference class
797 int x = (int) vh.getAndBitwiseOr(Void.class, 0x01234567);
798 });
799 checkWMTE(() -> { // value reference class
800 int x = (int) vh.getAndBitwiseOr(recv, Void.class);
801 });
802 checkWMTE(() -> { // reciever primitive class
803 int x = (int) vh.getAndBitwiseOr(0, 0x01234567);
804 });
805 // Incorrect return type
806 checkWMTE(() -> { // reference class
807 Void r = (Void) vh.getAndBitwiseOr(recv, 0x01234567);
808 });
809 checkWMTE(() -> { // primitive class
810 boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x01234567);
811 });
812 // Incorrect arity
813 checkWMTE(() -> { // 0
814 int x = (int) vh.getAndBitwiseOr();
815 });
816 checkWMTE(() -> { // >
817 int x = (int) vh.getAndBitwiseOr(recv, 0x01234567, Void.class);
818 });
819
820
821 // GetAndBitwiseAnd
822 // Incorrect argument types
823 checkNPE(() -> { // null receiver
824 int x = (int) vh.getAndBitwiseAnd(null, 0x01234567);
825 });
826 checkCCE(() -> { // receiver reference class
827 int x = (int) vh.getAndBitwiseAnd(Void.class, 0x01234567);
828 });
829 checkWMTE(() -> { // value reference class
830 int x = (int) vh.getAndBitwiseAnd(recv, Void.class);
831 });
832 checkWMTE(() -> { // reciever primitive class
833 int x = (int) vh.getAndBitwiseAnd(0, 0x01234567);
834 });
835 // Incorrect return type
836 checkWMTE(() -> { // reference class
837 Void r = (Void) vh.getAndBitwiseAnd(recv, 0x01234567);
838 });
839 checkWMTE(() -> { // primitive class
840 boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x01234567);
841 });
842 // Incorrect arity
843 checkWMTE(() -> { // 0
844 int x = (int) vh.getAndBitwiseAnd();
845 });
846 checkWMTE(() -> { // >
847 int x = (int) vh.getAndBitwiseAnd(recv, 0x01234567, Void.class);
848 });
849
850
851 // GetAndBitwiseAndAcquire
852 // Incorrect argument types
853 checkNPE(() -> { // null receiver
854 int x = (int) vh.getAndBitwiseAndAcquire(null, 0x01234567);
855 });
856 checkCCE(() -> { // receiver reference class
857 int x = (int) vh.getAndBitwiseAndAcquire(Void.class, 0x01234567);
858 });
859 checkWMTE(() -> { // value reference class
860 int x = (int) vh.getAndBitwiseAndAcquire(recv, Void.class);
861 });
862 checkWMTE(() -> { // reciever primitive class
863 int x = (int) vh.getAndBitwiseAndAcquire(0, 0x01234567);
864 });
865 // Incorrect return type
866 checkWMTE(() -> { // reference class
867 Void r = (Void) vh.getAndBitwiseAndAcquire(recv, 0x01234567);
868 });
869 checkWMTE(() -> { // primitive class
870 boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, 0x01234567);
871 });
872 // Incorrect arity
873 checkWMTE(() -> { // 0
874 int x = (int) vh.getAndBitwiseAndAcquire();
875 });
876 checkWMTE(() -> { // >
877 int x = (int) vh.getAndBitwiseAndAcquire(recv, 0x01234567, Void.class);
878 });
879
880
881 // GetAndBitwiseAndRelease
882 // Incorrect argument types
883 checkNPE(() -> { // null receiver
884 int x = (int) vh.getAndBitwiseAndRelease(null, 0x01234567);
885 });
886 checkCCE(() -> { // receiver reference class
887 int x = (int) vh.getAndBitwiseAnd(Void.class, 0x01234567);
888 });
889 checkWMTE(() -> { // value reference class
890 int x = (int) vh.getAndBitwiseAnd(recv, Void.class);
891 });
892 checkWMTE(() -> { // reciever primitive class
893 int x = (int) vh.getAndBitwiseAnd(0, 0x01234567);
894 });
895 // Incorrect return type
896 checkWMTE(() -> { // reference class
897 Void r = (Void) vh.getAndBitwiseAnd(recv, 0x01234567);
898 });
899 checkWMTE(() -> { // primitive class
900 boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x01234567);
901 });
902 // Incorrect arity
903 checkWMTE(() -> { // 0
904 int x = (int) vh.getAndBitwiseAnd();
905 });
906 checkWMTE(() -> { // >
907 int x = (int) vh.getAndBitwiseAnd(recv, 0x01234567, Void.class);
908 });
909
910
911 // GetAndBitwiseXor
912 // Incorrect argument types
913 checkNPE(() -> { // null receiver
914 int x = (int) vh.getAndBitwiseXor(null, 0x01234567);
915 });
916 checkCCE(() -> { // receiver reference class
917 int x = (int) vh.getAndBitwiseXor(Void.class, 0x01234567);
918 });
919 checkWMTE(() -> { // value reference class
920 int x = (int) vh.getAndBitwiseXor(recv, Void.class);
921 });
922 checkWMTE(() -> { // reciever primitive class
923 int x = (int) vh.getAndBitwiseXor(0, 0x01234567);
924 });
925 // Incorrect return type
926 checkWMTE(() -> { // reference class
927 Void r = (Void) vh.getAndBitwiseXor(recv, 0x01234567);
928 });
929 checkWMTE(() -> { // primitive class
930 boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x01234567);
931 });
932 // Incorrect arity
933 checkWMTE(() -> { // 0
934 int x = (int) vh.getAndBitwiseXor();
935 });
936 checkWMTE(() -> { // >
937 int x = (int) vh.getAndBitwiseXor(recv, 0x01234567, Void.class);
938 });
939
940
941 // GetAndBitwiseXorAcquire
942 // Incorrect argument types
943 checkNPE(() -> { // null receiver
944 int x = (int) vh.getAndBitwiseXorAcquire(null, 0x01234567);
945 });
946 checkCCE(() -> { // receiver reference class
947 int x = (int) vh.getAndBitwiseXorAcquire(Void.class, 0x01234567);
948 });
949 checkWMTE(() -> { // value reference class
950 int x = (int) vh.getAndBitwiseXorAcquire(recv, Void.class);
951 });
952 checkWMTE(() -> { // reciever primitive class
953 int x = (int) vh.getAndBitwiseXorAcquire(0, 0x01234567);
954 });
955 // Incorrect return type
956 checkWMTE(() -> { // reference class
957 Void r = (Void) vh.getAndBitwiseXorAcquire(recv, 0x01234567);
958 });
959 checkWMTE(() -> { // primitive class
960 boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, 0x01234567);
961 });
962 // Incorrect arity
963 checkWMTE(() -> { // 0
964 int x = (int) vh.getAndBitwiseXorAcquire();
965 });
966 checkWMTE(() -> { // >
967 int x = (int) vh.getAndBitwiseXorAcquire(recv, 0x01234567, Void.class);
968 });
969
970
971 // GetAndBitwiseXorRelease
972 // Incorrect argument types
973 checkNPE(() -> { // null receiver
974 int x = (int) vh.getAndBitwiseXorRelease(null, 0x01234567);
975 });
976 checkCCE(() -> { // receiver reference class
977 int x = (int) vh.getAndBitwiseXor(Void.class, 0x01234567);
978 });
979 checkWMTE(() -> { // value reference class
980 int x = (int) vh.getAndBitwiseXor(recv, Void.class);
981 });
982 checkWMTE(() -> { // reciever primitive class
983 int x = (int) vh.getAndBitwiseXor(0, 0x01234567);
984 });
985 // Incorrect return type
986 checkWMTE(() -> { // reference class
987 Void r = (Void) vh.getAndBitwiseXor(recv, 0x01234567);
988 });
989 checkWMTE(() -> { // primitive class
990 boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x01234567);
991 });
992 // Incorrect arity
993 checkWMTE(() -> { // 0
994 int x = (int) vh.getAndBitwiseXor();
995 });
996 checkWMTE(() -> { // >
997 int x = (int) vh.getAndBitwiseXor(recv, 0x01234567, Void.class);
998 });
999 }
1000
1001 static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeInt recv, Handles hs) throws Throwable {
1002 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
1003 // Incorrect argument types
1004 checkNPE(() -> { // null receiver
1005 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class)).
1006 invokeExact((VarHandleTestMethodTypeInt) null);
1007 });
1008 hs.checkWMTEOrCCE(() -> { // receiver reference class
1009 int x = (int) hs.get(am, methodType(int.class, Class.class)).
1010 invokeExact(Void.class);
1011 });
1012 checkWMTE(() -> { // receiver primitive class
1013 int x = (int) hs.get(am, methodType(int.class, int.class)).
1014 invokeExact(0);
1015 });
1016 // Incorrect return type
1017 checkWMTE(() -> { // reference class
1018 Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class)).
1019 invokeExact(recv);
1020 });
1021 checkWMTE(() -> { // primitive class
1022 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class)).
1023 invokeExact(recv);
1024 });
1025 // Incorrect arity
1026 checkWMTE(() -> { // 0
1027 int x = (int) hs.get(am, methodType(int.class)).
1028 invokeExact();
1029 });
1030 checkWMTE(() -> { // >
1031 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
1032 invokeExact(recv, Void.class);
1033 });
1034 }
1035
1036 for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
1037 // Incorrect argument types
1038 checkNPE(() -> { // null receiver
1039 hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class)).
1040 invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567);
1041 });
1042 hs.checkWMTEOrCCE(() -> { // receiver reference class
1043 hs.get(am, methodType(void.class, Class.class, int.class)).
1044 invokeExact(Void.class, 0x01234567);
1045 });
1046 checkWMTE(() -> { // value reference class
1047 hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, Class.class)).
1048 invokeExact(recv, Void.class);
1049 });
1050 checkWMTE(() -> { // receiver primitive class
1051 hs.get(am, methodType(void.class, int.class, int.class)).
1052 invokeExact(0, 0x01234567);
1053 });
1054 // Incorrect arity
1055 checkWMTE(() -> { // 0
1056 hs.get(am, methodType(void.class)).
1057 invokeExact();
1058 });
1059 checkWMTE(() -> { // >
1060 hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
1061 invokeExact(recv, 0x01234567, Void.class);
1062 });
1063 }
1064
1065 for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
1066 // Incorrect argument types
1067 checkNPE(() -> { // null receiver
1068 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
1069 invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567, 0x01234567);
1070 });
1071 hs.checkWMTEOrCCE(() -> { // receiver reference class
1072 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class)).
1073 invokeExact(Void.class, 0x01234567, 0x01234567);
1074 });
1075 checkWMTE(() -> { // expected reference class
1076 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
1077 invokeExact(recv, Void.class, 0x01234567);
1078 });
1079 checkWMTE(() -> { // actual reference class
1080 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
1081 invokeExact(recv, 0x01234567, Void.class);
1082 });
1083 checkWMTE(() -> { // receiver primitive class
1084 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , int.class, int.class)).
1085 invokeExact(0, 0x01234567, 0x01234567);
1086 });
1087 // Incorrect arity
1088 checkWMTE(() -> { // 0
1089 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
1090 invokeExact();
1091 });
1092 checkWMTE(() -> { // >
1093 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
1094 invokeExact(recv, 0x01234567, 0x01234567, Void.class);
1095 });
1096 }
1097
1098 for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
1099 checkNPE(() -> { // null receiver
1100 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
1101 invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567, 0x01234567);
1102 });
1103 hs.checkWMTEOrCCE(() -> { // receiver reference class
1104 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
1105 invokeExact(Void.class, 0x01234567, 0x01234567);
1106 });
1107 checkWMTE(() -> { // expected reference class
1108 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
1109 invokeExact(recv, Void.class, 0x01234567);
1110 });
1111 checkWMTE(() -> { // actual reference class
1112 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
1113 invokeExact(recv, 0x01234567, Void.class);
1114 });
1115 checkWMTE(() -> { // reciever primitive class
1116 int x = (int) hs.get(am, methodType(int.class, int.class , int.class, int.class)).
1117 invokeExact(0, 0x01234567, 0x01234567);
1118 });
1119 // Incorrect return type
1120 checkWMTE(() -> { // reference class
1121 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
1122 invokeExact(recv, 0x01234567, 0x01234567);
1123 });
1124 checkWMTE(() -> { // primitive class
1125 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
1126 invokeExact(recv, 0x01234567, 0x01234567);
1127 });
1128 // Incorrect arity
1129 checkWMTE(() -> { // 0
1130 int x = (int) hs.get(am, methodType(int.class)).
1131 invokeExact();
1132 });
1133 checkWMTE(() -> { // >
1134 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
1135 invokeExact(recv, 0x01234567, 0x01234567, Void.class);
1136 });
1137 }
1138
1139 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
1140 checkNPE(() -> { // null receiver
1141 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
1142 invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567);
1143 });
1144 hs.checkWMTEOrCCE(() -> { // receiver reference class
1145 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
1146 invokeExact(Void.class, 0x01234567);
1147 });
1148 checkWMTE(() -> { // value reference class
1149 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
1150 invokeExact(recv, Void.class);
1151 });
1152 checkWMTE(() -> { // reciever primitive class
1153 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
1154 invokeExact(0, 0x01234567);
1155 });
1156 // Incorrect return type
1157 checkWMTE(() -> { // reference class
1158 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
1159 invokeExact(recv, 0x01234567);
1160 });
1161 checkWMTE(() -> { // primitive class
1162 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
1163 invokeExact(recv, 0x01234567);
1164 });
1165 // Incorrect arity
1166 checkWMTE(() -> { // 0
1167 int x = (int) hs.get(am, methodType(int.class)).
1168 invokeExact();
1169 });
1170 checkWMTE(() -> { // >
1171 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
1172 invokeExact(recv, 0x01234567, Void.class);
1173 });
1174 }
1175
1176 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
1177 checkNPE(() -> { // null receiver
1178 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
1179 invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567);
1180 });
1181 hs.checkWMTEOrCCE(() -> { // receiver reference class
1182 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
1183 invokeExact(Void.class, 0x01234567);
1184 });
1185 checkWMTE(() -> { // value reference class
1186 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
1187 invokeExact(recv, Void.class);
1188 });
1189 checkWMTE(() -> { // reciever primitive class
1190 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
1191 invokeExact(0, 0x01234567);
1192 });
1193 // Incorrect return type
1194 checkWMTE(() -> { // reference class
1195 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
1196 invokeExact(recv, 0x01234567);
1197 });
1198 checkWMTE(() -> { // primitive class
1199 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
1200 invokeExact(recv, 0x01234567);
1201 });
1202 // Incorrect arity
1203 checkWMTE(() -> { // 0
1204 int x = (int) hs.get(am, methodType(int.class)).
1205 invokeExact();
1206 });
1207 checkWMTE(() -> { // >
1208 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
1209 invokeExact(recv, 0x01234567, Void.class);
1210 });
1211 }
1212
1213 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) {
1214 checkNPE(() -> { // null receiver
1215 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
1216 invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567);
1217 });
1218 hs.checkWMTEOrCCE(() -> { // receiver reference class
1219 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
1220 invokeExact(Void.class, 0x01234567);
1221 });
1222 checkWMTE(() -> { // value reference class
1223 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
1224 invokeExact(recv, Void.class);
1225 });
1226 checkWMTE(() -> { // reciever primitive class
1227 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
1228 invokeExact(0, 0x01234567);
1229 });
1230 // Incorrect return type
1231 checkWMTE(() -> { // reference class
1232 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
1233 invokeExact(recv, 0x01234567);
1234 });
1235 checkWMTE(() -> { // primitive class
1236 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
1237 invokeExact(recv, 0x01234567);
1238 });
1239 // Incorrect arity
1240 checkWMTE(() -> { // 0
1241 int x = (int) hs.get(am, methodType(int.class)).
1242 invokeExact();
1243 });
1244 checkWMTE(() -> { // >
1245 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
1246 invokeExact(recv, 0x01234567, Void.class);
1247 });
1248 }
1249 }
1250
1251
1252 static void testStaticFieldWrongMethodType(VarHandle vh) throws Throwable {
1253 // Get
1254 // Incorrect return type
1255 checkWMTE(() -> { // reference class
1256 Void x = (Void) vh.get();
1257 });
1258 checkWMTE(() -> { // primitive class
1259 boolean x = (boolean) vh.get();
1260 });
1261 // Incorrect arity
1262 checkWMTE(() -> { // >
1263 int x = (int) vh.get(Void.class);
1264 });
1265
1266
1267 // Set
1268 // Incorrect argument types
1269 checkWMTE(() -> { // value reference class
1270 vh.set(Void.class);
1271 });
1272 // Incorrect arity
1273 checkWMTE(() -> { // 0
1274 vh.set();
1275 });
1276 checkWMTE(() -> { // >
1277 vh.set(0x01234567, Void.class);
1278 });
1279
1280
1281 // GetVolatile
1282 // Incorrect return type
1283 checkWMTE(() -> { // reference class
1284 Void x = (Void) vh.getVolatile();
1285 });
1286 checkWMTE(() -> { // primitive class
1287 boolean x = (boolean) vh.getVolatile();
1288 });
1289 checkWMTE(() -> { // >
1290 int x = (int) vh.getVolatile(Void.class);
1291 });
1292
1293
1294 // SetVolatile
1295 // Incorrect argument types
1296 checkWMTE(() -> { // value reference class
1297 vh.setVolatile(Void.class);
1298 });
1299 // Incorrect arity
1300 checkWMTE(() -> { // 0
1301 vh.setVolatile();
1302 });
1303 checkWMTE(() -> { // >
1304 vh.setVolatile(0x01234567, Void.class);
1305 });
1306
1307
1308 // GetOpaque
1309 // Incorrect return type
1310 checkWMTE(() -> { // reference class
1311 Void x = (Void) vh.getOpaque();
1312 });
1313 checkWMTE(() -> { // primitive class
1314 boolean x = (boolean) vh.getOpaque();
1315 });
1316 checkWMTE(() -> { // >
1317 int x = (int) vh.getOpaque(Void.class);
1318 });
1319
1320
1321 // SetOpaque
1322 // Incorrect argument types
1323 checkWMTE(() -> { // value reference class
1324 vh.setOpaque(Void.class);
1325 });
1326 // Incorrect arity
1327 checkWMTE(() -> { // 0
1328 vh.setOpaque();
1329 });
1330 checkWMTE(() -> { // >
1331 vh.setOpaque(0x01234567, Void.class);
1332 });
1333
1334
1335 // GetAcquire
1336 // Incorrect return type
1337 checkWMTE(() -> { // reference class
1338 Void x = (Void) vh.getAcquire();
1339 });
1340 checkWMTE(() -> { // primitive class
1341 boolean x = (boolean) vh.getAcquire();
1342 });
1343 checkWMTE(() -> { // >
1344 int x = (int) vh.getAcquire(Void.class);
1345 });
1346
1347
1348 // SetRelease
1349 // Incorrect argument types
1350 checkWMTE(() -> { // value reference class
1351 vh.setRelease(Void.class);
1352 });
1353 // Incorrect arity
1354 checkWMTE(() -> { // 0
1355 vh.setRelease();
1356 });
1357 checkWMTE(() -> { // >
1358 vh.setRelease(0x01234567, Void.class);
1359 });
1360
1361
1362 // CompareAndSet
1363 // Incorrect argument types
1364 checkWMTE(() -> { // expected reference class
1365 boolean r = vh.compareAndSet(Void.class, 0x01234567);
1366 });
1367 checkWMTE(() -> { // actual reference class
1368 boolean r = vh.compareAndSet(0x01234567, Void.class);
1369 });
1370 // Incorrect arity
1371 checkWMTE(() -> { // 0
1372 boolean r = vh.compareAndSet();
1373 });
1374 checkWMTE(() -> { // >
1375 boolean r = vh.compareAndSet(0x01234567, 0x01234567, Void.class);
1376 });
1377
1378
1379 // WeakCompareAndSet
1380 // Incorrect argument types
1381 checkWMTE(() -> { // expected reference class
1382 boolean r = vh.weakCompareAndSetPlain(Void.class, 0x01234567);
1383 });
1384 checkWMTE(() -> { // actual reference class
1385 boolean r = vh.weakCompareAndSetPlain(0x01234567, Void.class);
1386 });
1387 // Incorrect arity
1388 checkWMTE(() -> { // 0
1389 boolean r = vh.weakCompareAndSetPlain();
1390 });
1391 checkWMTE(() -> { // >
1392 boolean r = vh.weakCompareAndSetPlain(0x01234567, 0x01234567, Void.class);
1393 });
1394
1395
1396 // WeakCompareAndSetVolatile
1397 // Incorrect argument types
1398 checkWMTE(() -> { // expected reference class
1399 boolean r = vh.weakCompareAndSet(Void.class, 0x01234567);
1400 });
1401 checkWMTE(() -> { // actual reference class
1402 boolean r = vh.weakCompareAndSet(0x01234567, Void.class);
1403 });
1404 // Incorrect arity
1405 checkWMTE(() -> { // 0
1406 boolean r = vh.weakCompareAndSet();
1407 });
1408 checkWMTE(() -> { // >
1409 boolean r = vh.weakCompareAndSet(0x01234567, 0x01234567, Void.class);
1410 });
1411
1412
1413 // WeakCompareAndSetAcquire
1414 // Incorrect argument types
1415 checkWMTE(() -> { // expected reference class
1416 boolean r = vh.weakCompareAndSetAcquire(Void.class, 0x01234567);
1417 });
1418 checkWMTE(() -> { // actual reference class
1419 boolean r = vh.weakCompareAndSetAcquire(0x01234567, Void.class);
1420 });
1421 // Incorrect arity
1422 checkWMTE(() -> { // 0
1423 boolean r = vh.weakCompareAndSetAcquire();
1424 });
1425 checkWMTE(() -> { // >
1426 boolean r = vh.weakCompareAndSetAcquire(0x01234567, 0x01234567, Void.class);
1427 });
1428
1429
1430 // WeakCompareAndSetRelease
1431 // Incorrect argument types
1432 checkWMTE(() -> { // expected reference class
1433 boolean r = vh.weakCompareAndSetRelease(Void.class, 0x01234567);
1434 });
1435 checkWMTE(() -> { // actual reference class
1436 boolean r = vh.weakCompareAndSetRelease(0x01234567, Void.class);
1437 });
1438 // Incorrect arity
1439 checkWMTE(() -> { // 0
1440 boolean r = vh.weakCompareAndSetRelease();
1441 });
1442 checkWMTE(() -> { // >
1443 boolean r = vh.weakCompareAndSetRelease(0x01234567, 0x01234567, Void.class);
1444 });
1445
1446
1447 // CompareAndExchange
1448 // Incorrect argument types
1449 checkWMTE(() -> { // expected reference class
1450 int x = (int) vh.compareAndExchange(Void.class, 0x01234567);
1451 });
1452 checkWMTE(() -> { // actual reference class
1453 int x = (int) vh.compareAndExchange(0x01234567, Void.class);
1454 });
1455 // Incorrect return type
1456 checkWMTE(() -> { // reference class
1457 Void r = (Void) vh.compareAndExchange(0x01234567, 0x01234567);
1458 });
1459 checkWMTE(() -> { // primitive class
1460 boolean x = (boolean) vh.compareAndExchange(0x01234567, 0x01234567);
1461 });
1462 // Incorrect arity
1463 checkWMTE(() -> { // 0
1464 int x = (int) vh.compareAndExchange();
1465 });
1466 checkWMTE(() -> { // >
1467 int x = (int) vh.compareAndExchange(0x01234567, 0x01234567, Void.class);
1468 });
1469
1470
1471 // CompareAndExchangeAcquire
1472 // Incorrect argument types
1473 checkWMTE(() -> { // expected reference class
1474 int x = (int) vh.compareAndExchangeAcquire(Void.class, 0x01234567);
1475 });
1476 checkWMTE(() -> { // actual reference class
1477 int x = (int) vh.compareAndExchangeAcquire(0x01234567, Void.class);
1478 });
1479 // Incorrect return type
1480 checkWMTE(() -> { // reference class
1481 Void r = (Void) vh.compareAndExchangeAcquire(0x01234567, 0x01234567);
1482 });
1483 checkWMTE(() -> { // primitive class
1484 boolean x = (boolean) vh.compareAndExchangeAcquire(0x01234567, 0x01234567);
1485 });
1486 // Incorrect arity
1487 checkWMTE(() -> { // 0
1488 int x = (int) vh.compareAndExchangeAcquire();
1489 });
1490 checkWMTE(() -> { // >
1491 int x = (int) vh.compareAndExchangeAcquire(0x01234567, 0x01234567, Void.class);
1492 });
1493
1494
1495 // CompareAndExchangeRelease
1496 // Incorrect argument types
1497 checkWMTE(() -> { // expected reference class
1498 int x = (int) vh.compareAndExchangeRelease(Void.class, 0x01234567);
1499 });
1500 checkWMTE(() -> { // actual reference class
1501 int x = (int) vh.compareAndExchangeRelease(0x01234567, Void.class);
1502 });
1503 // Incorrect return type
1504 checkWMTE(() -> { // reference class
1505 Void r = (Void) vh.compareAndExchangeRelease(0x01234567, 0x01234567);
1506 });
1507 checkWMTE(() -> { // primitive class
1508 boolean x = (boolean) vh.compareAndExchangeRelease(0x01234567, 0x01234567);
1509 });
1510 // Incorrect arity
1511 checkWMTE(() -> { // 0
1512 int x = (int) vh.compareAndExchangeRelease();
1513 });
1514 checkWMTE(() -> { // >
1515 int x = (int) vh.compareAndExchangeRelease(0x01234567, 0x01234567, Void.class);
1516 });
1517
1518
1519 // GetAndSet
1520 // Incorrect argument types
1521 checkWMTE(() -> { // value reference class
1522 int x = (int) vh.getAndSet(Void.class);
1523 });
1524 // Incorrect return type
1525 checkWMTE(() -> { // reference class
1526 Void r = (Void) vh.getAndSet(0x01234567);
1527 });
1528 checkWMTE(() -> { // primitive class
1529 boolean x = (boolean) vh.getAndSet(0x01234567);
1530 });
1531 // Incorrect arity
1532 checkWMTE(() -> { // 0
1533 int x = (int) vh.getAndSet();
1534 });
1535 checkWMTE(() -> { // >
1536 int x = (int) vh.getAndSet(0x01234567, Void.class);
1537 });
1538
1539
1540 // GetAndSetAcquire
1541 // Incorrect argument types
1542 checkWMTE(() -> { // value reference class
1543 int x = (int) vh.getAndSetAcquire(Void.class);
1544 });
1545 // Incorrect return type
1546 checkWMTE(() -> { // reference class
1547 Void r = (Void) vh.getAndSetAcquire(0x01234567);
1548 });
1549 checkWMTE(() -> { // primitive class
1550 boolean x = (boolean) vh.getAndSetAcquire(0x01234567);
1551 });
1552 // Incorrect arity
1553 checkWMTE(() -> { // 0
1554 int x = (int) vh.getAndSetAcquire();
1555 });
1556 checkWMTE(() -> { // >
1557 int x = (int) vh.getAndSetAcquire(0x01234567, Void.class);
1558 });
1559
1560
1561 // GetAndSetRelease
1562 // Incorrect argument types
1563 checkWMTE(() -> { // value reference class
1564 int x = (int) vh.getAndSetRelease(Void.class);
1565 });
1566 // Incorrect return type
1567 checkWMTE(() -> { // reference class
1568 Void r = (Void) vh.getAndSetRelease(0x01234567);
1569 });
1570 checkWMTE(() -> { // primitive class
1571 boolean x = (boolean) vh.getAndSetRelease(0x01234567);
1572 });
1573 // Incorrect arity
1574 checkWMTE(() -> { // 0
1575 int x = (int) vh.getAndSetRelease();
1576 });
1577 checkWMTE(() -> { // >
1578 int x = (int) vh.getAndSetRelease(0x01234567, Void.class);
1579 });
1580
1581 // GetAndAdd
1582 // Incorrect argument types
1583 checkWMTE(() -> { // value reference class
1584 int x = (int) vh.getAndAdd(Void.class);
1585 });
1586 // Incorrect return type
1587 checkWMTE(() -> { // reference class
1588 Void r = (Void) vh.getAndAdd(0x01234567);
1589 });
1590 checkWMTE(() -> { // primitive class
1591 boolean x = (boolean) vh.getAndAdd(0x01234567);
1592 });
1593 // Incorrect arity
1594 checkWMTE(() -> { // 0
1595 int x = (int) vh.getAndAdd();
1596 });
1597 checkWMTE(() -> { // >
1598 int x = (int) vh.getAndAdd(0x01234567, Void.class);
1599 });
1600
1601
1602 // GetAndAddAcquire
1603 // Incorrect argument types
1604 checkWMTE(() -> { // value reference class
1605 int x = (int) vh.getAndAddAcquire(Void.class);
1606 });
1607 // Incorrect return type
1608 checkWMTE(() -> { // reference class
1609 Void r = (Void) vh.getAndAddAcquire(0x01234567);
1610 });
1611 checkWMTE(() -> { // primitive class
1612 boolean x = (boolean) vh.getAndAddAcquire(0x01234567);
1613 });
1614 // Incorrect arity
1615 checkWMTE(() -> { // 0
1616 int x = (int) vh.getAndAddAcquire();
1617 });
1618 checkWMTE(() -> { // >
1619 int x = (int) vh.getAndAddAcquire(0x01234567, Void.class);
1620 });
1621
1622
1623 // GetAndAddRelease
1624 // Incorrect argument types
1625 checkWMTE(() -> { // value reference class
1626 int x = (int) vh.getAndAddRelease(Void.class);
1627 });
1628 // Incorrect return type
1629 checkWMTE(() -> { // reference class
1630 Void r = (Void) vh.getAndAddRelease(0x01234567);
1631 });
1632 checkWMTE(() -> { // primitive class
1633 boolean x = (boolean) vh.getAndAddRelease(0x01234567);
1634 });
1635 // Incorrect arity
1636 checkWMTE(() -> { // 0
1637 int x = (int) vh.getAndAddRelease();
1638 });
1639 checkWMTE(() -> { // >
1640 int x = (int) vh.getAndAddRelease(0x01234567, Void.class);
1641 });
1642
1643 // GetAndBitwiseOr
1644 // Incorrect argument types
1645 checkWMTE(() -> { // value reference class
1646 int x = (int) vh.getAndBitwiseOr(Void.class);
1647 });
1648 // Incorrect return type
1649 checkWMTE(() -> { // reference class
1650 Void r = (Void) vh.getAndBitwiseOr(0x01234567);
1651 });
1652 checkWMTE(() -> { // primitive class
1653 boolean x = (boolean) vh.getAndBitwiseOr(0x01234567);
1654 });
1655 // Incorrect arity
1656 checkWMTE(() -> { // 0
1657 int x = (int) vh.getAndBitwiseOr();
1658 });
1659 checkWMTE(() -> { // >
1660 int x = (int) vh.getAndBitwiseOr(0x01234567, Void.class);
1661 });
1662
1663
1664 // GetAndBitwiseOrAcquire
1665 // Incorrect argument types
1666 checkWMTE(() -> { // value reference class
1667 int x = (int) vh.getAndBitwiseOrAcquire(Void.class);
1668 });
1669 // Incorrect return type
1670 checkWMTE(() -> { // reference class
1671 Void r = (Void) vh.getAndBitwiseOrAcquire(0x01234567);
1672 });
1673 checkWMTE(() -> { // primitive class
1674 boolean x = (boolean) vh.getAndBitwiseOrAcquire(0x01234567);
1675 });
1676 // Incorrect arity
1677 checkWMTE(() -> { // 0
1678 int x = (int) vh.getAndBitwiseOrAcquire();
1679 });
1680 checkWMTE(() -> { // >
1681 int x = (int) vh.getAndBitwiseOrAcquire(0x01234567, Void.class);
1682 });
1683
1684
1685 // GetAndBitwiseOrReleaseRelease
1686 // Incorrect argument types
1687 checkWMTE(() -> { // value reference class
1688 int x = (int) vh.getAndBitwiseOrRelease(Void.class);
1689 });
1690 // Incorrect return type
1691 checkWMTE(() -> { // reference class
1692 Void r = (Void) vh.getAndBitwiseOrRelease(0x01234567);
1693 });
1694 checkWMTE(() -> { // primitive class
1695 boolean x = (boolean) vh.getAndBitwiseOrRelease(0x01234567);
1696 });
1697 // Incorrect arity
1698 checkWMTE(() -> { // 0
1699 int x = (int) vh.getAndBitwiseOrRelease();
1700 });
1701 checkWMTE(() -> { // >
1702 int x = (int) vh.getAndBitwiseOrRelease(0x01234567, Void.class);
1703 });
1704
1705
1706 // GetAndBitwiseAnd
1707 // Incorrect argument types
1708 checkWMTE(() -> { // value reference class
1709 int x = (int) vh.getAndBitwiseAnd(Void.class);
1710 });
1711 // Incorrect return type
1712 checkWMTE(() -> { // reference class
1713 Void r = (Void) vh.getAndBitwiseAnd(0x01234567);
1714 });
1715 checkWMTE(() -> { // primitive class
1716 boolean x = (boolean) vh.getAndBitwiseAnd(0x01234567);
1717 });
1718 // Incorrect arity
1719 checkWMTE(() -> { // 0
1720 int x = (int) vh.getAndBitwiseAnd();
1721 });
1722 checkWMTE(() -> { // >
1723 int x = (int) vh.getAndBitwiseAnd(0x01234567, Void.class);
1724 });
1725
1726
1727 // GetAndBitwiseAndAcquire
1728 // Incorrect argument types
1729 checkWMTE(() -> { // value reference class
1730 int x = (int) vh.getAndBitwiseAndAcquire(Void.class);
1731 });
1732 // Incorrect return type
1733 checkWMTE(() -> { // reference class
1734 Void r = (Void) vh.getAndBitwiseAndAcquire(0x01234567);
1735 });
1736 checkWMTE(() -> { // primitive class
1737 boolean x = (boolean) vh.getAndBitwiseAndAcquire(0x01234567);
1738 });
1739 // Incorrect arity
1740 checkWMTE(() -> { // 0
1741 int x = (int) vh.getAndBitwiseAndAcquire();
1742 });
1743 checkWMTE(() -> { // >
1744 int x = (int) vh.getAndBitwiseAndAcquire(0x01234567, Void.class);
1745 });
1746
1747
1748 // GetAndBitwiseAndReleaseRelease
1749 // Incorrect argument types
1750 checkWMTE(() -> { // value reference class
1751 int x = (int) vh.getAndBitwiseAndRelease(Void.class);
1752 });
1753 // Incorrect return type
1754 checkWMTE(() -> { // reference class
1755 Void r = (Void) vh.getAndBitwiseAndRelease(0x01234567);
1756 });
1757 checkWMTE(() -> { // primitive class
1758 boolean x = (boolean) vh.getAndBitwiseAndRelease(0x01234567);
1759 });
1760 // Incorrect arity
1761 checkWMTE(() -> { // 0
1762 int x = (int) vh.getAndBitwiseAndRelease();
1763 });
1764 checkWMTE(() -> { // >
1765 int x = (int) vh.getAndBitwiseAndRelease(0x01234567, Void.class);
1766 });
1767
1768
1769 // GetAndBitwiseXor
1770 // Incorrect argument types
1771 checkWMTE(() -> { // value reference class
1772 int x = (int) vh.getAndBitwiseXor(Void.class);
1773 });
1774 // Incorrect return type
1775 checkWMTE(() -> { // reference class
1776 Void r = (Void) vh.getAndBitwiseXor(0x01234567);
1777 });
1778 checkWMTE(() -> { // primitive class
1779 boolean x = (boolean) vh.getAndBitwiseXor(0x01234567);
1780 });
1781 // Incorrect arity
1782 checkWMTE(() -> { // 0
1783 int x = (int) vh.getAndBitwiseXor();
1784 });
1785 checkWMTE(() -> { // >
1786 int x = (int) vh.getAndBitwiseXor(0x01234567, Void.class);
1787 });
1788
1789
1790 // GetAndBitwiseXorAcquire
1791 // Incorrect argument types
1792 checkWMTE(() -> { // value reference class
1793 int x = (int) vh.getAndBitwiseXorAcquire(Void.class);
1794 });
1795 // Incorrect return type
1796 checkWMTE(() -> { // reference class
1797 Void r = (Void) vh.getAndBitwiseXorAcquire(0x01234567);
1798 });
1799 checkWMTE(() -> { // primitive class
1800 boolean x = (boolean) vh.getAndBitwiseXorAcquire(0x01234567);
1801 });
1802 // Incorrect arity
1803 checkWMTE(() -> { // 0
1804 int x = (int) vh.getAndBitwiseXorAcquire();
1805 });
1806 checkWMTE(() -> { // >
1807 int x = (int) vh.getAndBitwiseXorAcquire(0x01234567, Void.class);
1808 });
1809
1810
1811 // GetAndBitwiseXorReleaseRelease
1812 // Incorrect argument types
1813 checkWMTE(() -> { // value reference class
1814 int x = (int) vh.getAndBitwiseXorRelease(Void.class);
1815 });
1816 // Incorrect return type
1817 checkWMTE(() -> { // reference class
1818 Void r = (Void) vh.getAndBitwiseXorRelease(0x01234567);
1819 });
1820 checkWMTE(() -> { // primitive class
1821 boolean x = (boolean) vh.getAndBitwiseXorRelease(0x01234567);
1822 });
1823 // Incorrect arity
1824 checkWMTE(() -> { // 0
1825 int x = (int) vh.getAndBitwiseXorRelease();
1826 });
1827 checkWMTE(() -> { // >
1828 int x = (int) vh.getAndBitwiseXorRelease(0x01234567, Void.class);
1829 });
1830 }
1831
1832 static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
1833 int i = 0;
1834
1835 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
1836 // Incorrect return type
1837 checkWMTE(() -> { // reference class
1838 Void x = (Void) hs.get(am, methodType(Void.class)).
1839 invokeExact();
1840 });
1841 checkWMTE(() -> { // primitive class
1842 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
1843 invokeExact();
1844 });
1845 // Incorrect arity
1846 checkWMTE(() -> { // >
1847 int x = (int) hs.get(am, methodType(Class.class)).
1848 invokeExact(Void.class);
1849 });
1850 }
1851
1852 for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
1853 checkWMTE(() -> { // value reference class
1854 hs.get(am, methodType(void.class, Class.class)).
1855 invokeExact(Void.class);
1856 });
1857 // Incorrect arity
1858 checkWMTE(() -> { // 0
1859 hs.get(am, methodType(void.class)).
1860 invokeExact();
1861 });
1862 checkWMTE(() -> { // >
1863 hs.get(am, methodType(void.class, int.class, Class.class)).
1864 invokeExact(0x01234567, Void.class);
1865 });
1866 }
1867 for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
1868 // Incorrect argument types
1869 checkWMTE(() -> { // expected reference class
1870 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
1871 invokeExact(Void.class, 0x01234567);
1872 });
1873 checkWMTE(() -> { // actual reference class
1874 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, Class.class)).
1875 invokeExact(0x01234567, Void.class);
1876 });
1877 // Incorrect arity
1878 checkWMTE(() -> { // 0
1879 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
1880 invokeExact();
1881 });
1882 checkWMTE(() -> { // >
1883 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, Class.class)).
1884 invokeExact(0x01234567, 0x01234567, Void.class);
1885 });
1886 }
1887
1888 for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
1889 // Incorrect argument types
1890 checkWMTE(() -> { // expected reference class
1891 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
1892 invokeExact(Void.class, 0x01234567);
1893 });
1894 checkWMTE(() -> { // actual reference class
1895 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
1896 invokeExact(0x01234567, Void.class);
1897 });
1898 // Incorrect return type
1899 checkWMTE(() -> { // reference class
1900 Void r = (Void) hs.get(am, methodType(Void.class, int.class, int.class)).
1901 invokeExact(0x01234567, 0x01234567);
1902 });
1903 checkWMTE(() -> { // primitive class
1904 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
1905 invokeExact(0x01234567, 0x01234567);
1906 });
1907 // Incorrect arity
1908 checkWMTE(() -> { // 0
1909 int x = (int) hs.get(am, methodType(int.class)).
1910 invokeExact();
1911 });
1912 checkWMTE(() -> { // >
1913 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, Class.class)).
1914 invokeExact(0x01234567, 0x01234567, Void.class);
1915 });
1916 }
1917
1918 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
1919 // Incorrect argument types
1920 checkWMTE(() -> { // value reference class
1921 int x = (int) hs.get(am, methodType(int.class, Class.class)).
1922 invokeExact(Void.class);
1923 });
1924 // Incorrect return type
1925 checkWMTE(() -> { // reference class
1926 Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
1927 invokeExact(0x01234567);
1928 });
1929 checkWMTE(() -> { // primitive class
1930 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
1931 invokeExact(0x01234567);
1932 });
1933 // Incorrect arity
1934 checkWMTE(() -> { // 0
1935 int x = (int) hs.get(am, methodType(int.class)).
1936 invokeExact();
1937 });
1938 checkWMTE(() -> { // >
1939 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
1940 invokeExact(0x01234567, Void.class);
1941 });
1942 }
1943
1944 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
1945 // Incorrect argument types
1946 checkWMTE(() -> { // value reference class
1947 int x = (int) hs.get(am, methodType(int.class, Class.class)).
1948 invokeExact(Void.class);
1949 });
1950 // Incorrect return type
1951 checkWMTE(() -> { // reference class
1952 Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
1953 invokeExact(0x01234567);
1954 });
1955 checkWMTE(() -> { // primitive class
1956 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
1957 invokeExact(0x01234567);
1958 });
1959 // Incorrect arity
1960 checkWMTE(() -> { // 0
1961 int x = (int) hs.get(am, methodType(int.class)).
1962 invokeExact();
1963 });
1964 checkWMTE(() -> { // >
1965 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
1966 invokeExact(0x01234567, Void.class);
1967 });
1968 }
1969
1970 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) {
1971 // Incorrect argument types
1972 checkWMTE(() -> { // value reference class
1973 int x = (int) hs.get(am, methodType(int.class, Class.class)).
1974 invokeExact(Void.class);
1975 });
1976 // Incorrect return type
1977 checkWMTE(() -> { // reference class
1978 Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
1979 invokeExact(0x01234567);
1980 });
1981 checkWMTE(() -> { // primitive class
1982 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
1983 invokeExact(0x01234567);
1984 });
1985 // Incorrect arity
1986 checkWMTE(() -> { // 0
1987 int x = (int) hs.get(am, methodType(int.class)).
1988 invokeExact();
1989 });
1990 checkWMTE(() -> { // >
1991 int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
1992 invokeExact(0x01234567, Void.class);
1993 });
1994 }
1995 }
1996
1997
1998 static void testArrayWrongMethodType(VarHandle vh) throws Throwable {
1999 int[] array = new int[10];
2000 Arrays.fill(array, 0x01234567);
2001
2002 // Get
2003 // Incorrect argument types
2004 checkNPE(() -> { // null array
2005 int x = (int) vh.get(null, 0);
2006 });
2007 checkCCE(() -> { // array reference class
2008 int x = (int) vh.get(Void.class, 0);
2009 });
2010 checkWMTE(() -> { // array primitive class
2011 int x = (int) vh.get(0, 0);
2012 });
2013 checkWMTE(() -> { // index reference class
2014 int x = (int) vh.get(array, Void.class);
2015 });
2016 // Incorrect return type
2017 checkWMTE(() -> { // reference class
2018 Void x = (Void) vh.get(array, 0);
2019 });
2020 checkWMTE(() -> { // primitive class
2021 boolean x = (boolean) vh.get(array, 0);
2022 });
2023 // Incorrect arity
2024 checkWMTE(() -> { // 0
2025 int x = (int) vh.get();
2026 });
2027 checkWMTE(() -> { // >
2028 int x = (int) vh.get(array, 0, Void.class);
2029 });
2030
2031
2032 // Set
2033 // Incorrect argument types
2034 checkNPE(() -> { // null array
2035 vh.set(null, 0, 0x01234567);
2036 });
2037 checkCCE(() -> { // array reference class
2038 vh.set(Void.class, 0, 0x01234567);
2039 });
2040 checkWMTE(() -> { // value reference class
2041 vh.set(array, 0, Void.class);
2042 });
2043 checkWMTE(() -> { // receiver primitive class
2044 vh.set(0, 0, 0x01234567);
2045 });
2046 checkWMTE(() -> { // index reference class
2047 vh.set(array, Void.class, 0x01234567);
2048 });
2049 // Incorrect arity
2050 checkWMTE(() -> { // 0
2051 vh.set();
2052 });
2053 checkWMTE(() -> { // >
2054 vh.set(array, 0, 0x01234567, Void.class);
2055 });
2056
2057
2058 // GetVolatile
2059 // Incorrect argument types
2060 checkNPE(() -> { // null array
2061 int x = (int) vh.getVolatile(null, 0);
2062 });
2063 checkCCE(() -> { // array reference class
2064 int x = (int) vh.getVolatile(Void.class, 0);
2065 });
2066 checkWMTE(() -> { // array primitive class
2067 int x = (int) vh.getVolatile(0, 0);
2068 });
2069 checkWMTE(() -> { // index reference class
2070 int x = (int) vh.getVolatile(array, Void.class);
2071 });
2072 // Incorrect return type
2073 checkWMTE(() -> { // reference class
2074 Void x = (Void) vh.getVolatile(array, 0);
2075 });
2076 checkWMTE(() -> { // primitive class
2077 boolean x = (boolean) vh.getVolatile(array, 0);
2078 });
2079 // Incorrect arity
2080 checkWMTE(() -> { // 0
2081 int x = (int) vh.getVolatile();
2082 });
2083 checkWMTE(() -> { // >
2084 int x = (int) vh.getVolatile(array, 0, Void.class);
2085 });
2086
2087
2088 // SetVolatile
2089 // Incorrect argument types
2090 checkNPE(() -> { // null array
2091 vh.setVolatile(null, 0, 0x01234567);
2092 });
2093 checkCCE(() -> { // array reference class
2094 vh.setVolatile(Void.class, 0, 0x01234567);
2095 });
2096 checkWMTE(() -> { // value reference class
2097 vh.setVolatile(array, 0, Void.class);
2098 });
2099 checkWMTE(() -> { // receiver primitive class
2100 vh.setVolatile(0, 0, 0x01234567);
2101 });
2102 checkWMTE(() -> { // index reference class
2103 vh.setVolatile(array, Void.class, 0x01234567);
2104 });
2105 // Incorrect arity
2106 checkWMTE(() -> { // 0
2107 vh.setVolatile();
2108 });
2109 checkWMTE(() -> { // >
2110 vh.setVolatile(array, 0, 0x01234567, Void.class);
2111 });
2112
2113
2114 // GetOpaque
2115 // Incorrect argument types
2116 checkNPE(() -> { // null array
2117 int x = (int) vh.getOpaque(null, 0);
2118 });
2119 checkCCE(() -> { // array reference class
2120 int x = (int) vh.getOpaque(Void.class, 0);
2121 });
2122 checkWMTE(() -> { // array primitive class
2123 int x = (int) vh.getOpaque(0, 0);
2124 });
2125 checkWMTE(() -> { // index reference class
2126 int x = (int) vh.getOpaque(array, Void.class);
2127 });
2128 // Incorrect return type
2129 checkWMTE(() -> { // reference class
2130 Void x = (Void) vh.getOpaque(array, 0);
2131 });
2132 checkWMTE(() -> { // primitive class
2133 boolean x = (boolean) vh.getOpaque(array, 0);
2134 });
2135 // Incorrect arity
2136 checkWMTE(() -> { // 0
2137 int x = (int) vh.getOpaque();
2138 });
2139 checkWMTE(() -> { // >
2140 int x = (int) vh.getOpaque(array, 0, Void.class);
2141 });
2142
2143
2144 // SetOpaque
2145 // Incorrect argument types
2146 checkNPE(() -> { // null array
2147 vh.setOpaque(null, 0, 0x01234567);
2148 });
2149 checkCCE(() -> { // array reference class
2150 vh.setOpaque(Void.class, 0, 0x01234567);
2151 });
2152 checkWMTE(() -> { // value reference class
2153 vh.setOpaque(array, 0, Void.class);
2154 });
2155 checkWMTE(() -> { // receiver primitive class
2156 vh.setOpaque(0, 0, 0x01234567);
2157 });
2158 checkWMTE(() -> { // index reference class
2159 vh.setOpaque(array, Void.class, 0x01234567);
2160 });
2161 // Incorrect arity
2162 checkWMTE(() -> { // 0
2163 vh.setOpaque();
2164 });
2165 checkWMTE(() -> { // >
2166 vh.setOpaque(array, 0, 0x01234567, Void.class);
2167 });
2168
2169
2170 // GetAcquire
2171 // Incorrect argument types
2172 checkNPE(() -> { // null array
2173 int x = (int) vh.getAcquire(null, 0);
2174 });
2175 checkCCE(() -> { // array reference class
2176 int x = (int) vh.getAcquire(Void.class, 0);
2177 });
2178 checkWMTE(() -> { // array primitive class
2179 int x = (int) vh.getAcquire(0, 0);
2180 });
2181 checkWMTE(() -> { // index reference class
2182 int x = (int) vh.getAcquire(array, Void.class);
2183 });
2184 // Incorrect return type
2185 checkWMTE(() -> { // reference class
2186 Void x = (Void) vh.getAcquire(array, 0);
2187 });
2188 checkWMTE(() -> { // primitive class
2189 boolean x = (boolean) vh.getAcquire(array, 0);
2190 });
2191 // Incorrect arity
2192 checkWMTE(() -> { // 0
2193 int x = (int) vh.getAcquire();
2194 });
2195 checkWMTE(() -> { // >
2196 int x = (int) vh.getAcquire(array, 0, Void.class);
2197 });
2198
2199
2200 // SetRelease
2201 // Incorrect argument types
2202 checkNPE(() -> { // null array
2203 vh.setRelease(null, 0, 0x01234567);
2204 });
2205 checkCCE(() -> { // array reference class
2206 vh.setRelease(Void.class, 0, 0x01234567);
2207 });
2208 checkWMTE(() -> { // value reference class
2209 vh.setRelease(array, 0, Void.class);
2210 });
2211 checkWMTE(() -> { // receiver primitive class
2212 vh.setRelease(0, 0, 0x01234567);
2213 });
2214 checkWMTE(() -> { // index reference class
2215 vh.setRelease(array, Void.class, 0x01234567);
2216 });
2217 // Incorrect arity
2218 checkWMTE(() -> { // 0
2219 vh.setRelease();
2220 });
2221 checkWMTE(() -> { // >
2222 vh.setRelease(array, 0, 0x01234567, Void.class);
2223 });
2224
2225
2226 // CompareAndSet
2227 // Incorrect argument types
2228 checkNPE(() -> { // null receiver
2229 boolean r = vh.compareAndSet(null, 0, 0x01234567, 0x01234567);
2230 });
2231 checkCCE(() -> { // receiver reference class
2232 boolean r = vh.compareAndSet(Void.class, 0, 0x01234567, 0x01234567);
2233 });
2234 checkWMTE(() -> { // expected reference class
2235 boolean r = vh.compareAndSet(array, 0, Void.class, 0x01234567);
2236 });
2237 checkWMTE(() -> { // actual reference class
2238 boolean r = vh.compareAndSet(array, 0, 0x01234567, Void.class);
2239 });
2240 checkWMTE(() -> { // receiver primitive class
2241 boolean r = vh.compareAndSet(0, 0, 0x01234567, 0x01234567);
2242 });
2243 checkWMTE(() -> { // index reference class
2244 boolean r = vh.compareAndSet(array, Void.class, 0x01234567, 0x01234567);
2245 });
2246 // Incorrect arity
2247 checkWMTE(() -> { // 0
2248 boolean r = vh.compareAndSet();
2249 });
2250 checkWMTE(() -> { // >
2251 boolean r = vh.compareAndSet(array, 0, 0x01234567, 0x01234567, Void.class);
2252 });
2253
2254
2255 // WeakCompareAndSet
2256 // Incorrect argument types
2257 checkNPE(() -> { // null receiver
2258 boolean r = vh.weakCompareAndSetPlain(null, 0, 0x01234567, 0x01234567);
2259 });
2260 checkCCE(() -> { // receiver reference class
2261 boolean r = vh.weakCompareAndSetPlain(Void.class, 0, 0x01234567, 0x01234567);
2262 });
2263 checkWMTE(() -> { // expected reference class
2264 boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, 0x01234567);
2265 });
2266 checkWMTE(() -> { // actual reference class
2267 boolean r = vh.weakCompareAndSetPlain(array, 0, 0x01234567, Void.class);
2268 });
2269 checkWMTE(() -> { // receiver primitive class
2270 boolean r = vh.weakCompareAndSetPlain(0, 0, 0x01234567, 0x01234567);
2271 });
2272 checkWMTE(() -> { // index reference class
2273 boolean r = vh.weakCompareAndSetPlain(array, Void.class, 0x01234567, 0x01234567);
2274 });
2275 // Incorrect arity
2276 checkWMTE(() -> { // 0
2277 boolean r = vh.weakCompareAndSetPlain();
2278 });
2279 checkWMTE(() -> { // >
2280 boolean r = vh.weakCompareAndSetPlain(array, 0, 0x01234567, 0x01234567, Void.class);
2281 });
2282
2283
2284 // WeakCompareAndSetVolatile
2285 // Incorrect argument types
2286 checkNPE(() -> { // null receiver
2287 boolean r = vh.weakCompareAndSet(null, 0, 0x01234567, 0x01234567);
2288 });
2289 checkCCE(() -> { // receiver reference class
2290 boolean r = vh.weakCompareAndSet(Void.class, 0, 0x01234567, 0x01234567);
2291 });
2292 checkWMTE(() -> { // expected reference class
2293 boolean r = vh.weakCompareAndSet(array, 0, Void.class, 0x01234567);
2294 });
2295 checkWMTE(() -> { // actual reference class
2296 boolean r = vh.weakCompareAndSet(array, 0, 0x01234567, Void.class);
2297 });
2298 checkWMTE(() -> { // receiver primitive class
2299 boolean r = vh.weakCompareAndSet(0, 0, 0x01234567, 0x01234567);
2300 });
2301 checkWMTE(() -> { // index reference class
2302 boolean r = vh.weakCompareAndSet(array, Void.class, 0x01234567, 0x01234567);
2303 });
2304 // Incorrect arity
2305 checkWMTE(() -> { // 0
2306 boolean r = vh.weakCompareAndSet();
2307 });
2308 checkWMTE(() -> { // >
2309 boolean r = vh.weakCompareAndSet(array, 0, 0x01234567, 0x01234567, Void.class);
2310 });
2311
2312
2313 // WeakCompareAndSetAcquire
2314 // Incorrect argument types
2315 checkNPE(() -> { // null receiver
2316 boolean r = vh.weakCompareAndSetAcquire(null, 0, 0x01234567, 0x01234567);
2317 });
2318 checkCCE(() -> { // receiver reference class
2319 boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, 0x01234567, 0x01234567);
2320 });
2321 checkWMTE(() -> { // expected reference class
2322 boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, 0x01234567);
2323 });
2324 checkWMTE(() -> { // actual reference class
2325 boolean r = vh.weakCompareAndSetAcquire(array, 0, 0x01234567, Void.class);
2326 });
2327 checkWMTE(() -> { // receiver primitive class
2328 boolean r = vh.weakCompareAndSetAcquire(0, 0, 0x01234567, 0x01234567);
2329 });
2330 checkWMTE(() -> { // index reference class
2331 boolean r = vh.weakCompareAndSetAcquire(array, Void.class, 0x01234567, 0x01234567);
2332 });
2333 // Incorrect arity
2334 checkWMTE(() -> { // 0
2335 boolean r = vh.weakCompareAndSetAcquire();
2336 });
2337 checkWMTE(() -> { // >
2338 boolean r = vh.weakCompareAndSetAcquire(array, 0, 0x01234567, 0x01234567, Void.class);
2339 });
2340
2341
2342 // WeakCompareAndSetRelease
2343 // Incorrect argument types
2344 checkNPE(() -> { // null receiver
2345 boolean r = vh.weakCompareAndSetRelease(null, 0, 0x01234567, 0x01234567);
2346 });
2347 checkCCE(() -> { // receiver reference class
2348 boolean r = vh.weakCompareAndSetRelease(Void.class, 0, 0x01234567, 0x01234567);
2349 });
2350 checkWMTE(() -> { // expected reference class
2351 boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, 0x01234567);
2352 });
2353 checkWMTE(() -> { // actual reference class
2354 boolean r = vh.weakCompareAndSetRelease(array, 0, 0x01234567, Void.class);
2355 });
2356 checkWMTE(() -> { // receiver primitive class
2357 boolean r = vh.weakCompareAndSetRelease(0, 0, 0x01234567, 0x01234567);
2358 });
2359 checkWMTE(() -> { // index reference class
2360 boolean r = vh.weakCompareAndSetRelease(array, Void.class, 0x01234567, 0x01234567);
2361 });
2362 // Incorrect arity
2363 checkWMTE(() -> { // 0
2364 boolean r = vh.weakCompareAndSetRelease();
2365 });
2366 checkWMTE(() -> { // >
2367 boolean r = vh.weakCompareAndSetRelease(array, 0, 0x01234567, 0x01234567, Void.class);
2368 });
2369
2370
2371 // CompareAndExchange
2372 // Incorrect argument types
2373 checkNPE(() -> { // null receiver
2374 int x = (int) vh.compareAndExchange(null, 0, 0x01234567, 0x01234567);
2375 });
2376 checkCCE(() -> { // array reference class
2377 int x = (int) vh.compareAndExchange(Void.class, 0, 0x01234567, 0x01234567);
2378 });
2379 checkWMTE(() -> { // expected reference class
2380 int x = (int) vh.compareAndExchange(array, 0, Void.class, 0x01234567);
2381 });
2382 checkWMTE(() -> { // actual reference class
2383 int x = (int) vh.compareAndExchange(array, 0, 0x01234567, Void.class);
2384 });
2385 checkWMTE(() -> { // array primitive class
2386 int x = (int) vh.compareAndExchange(0, 0, 0x01234567, 0x01234567);
2387 });
2388 checkWMTE(() -> { // index reference class
2389 int x = (int) vh.compareAndExchange(array, Void.class, 0x01234567, 0x01234567);
2390 });
2391 // Incorrect return type
2392 checkWMTE(() -> { // reference class
2393 Void r = (Void) vh.compareAndExchange(array, 0, 0x01234567, 0x01234567);
2394 });
2395 checkWMTE(() -> { // primitive class
2396 boolean x = (boolean) vh.compareAndExchange(array, 0, 0x01234567, 0x01234567);
2397 });
2398 // Incorrect arity
2399 checkWMTE(() -> { // 0
2400 int x = (int) vh.compareAndExchange();
2401 });
2402 checkWMTE(() -> { // >
2403 int x = (int) vh.compareAndExchange(array, 0, 0x01234567, 0x01234567, Void.class);
2404 });
2405
2406
2407 // CompareAndExchangeAcquire
2408 // Incorrect argument types
2409 checkNPE(() -> { // null receiver
2410 int x = (int) vh.compareAndExchangeAcquire(null, 0, 0x01234567, 0x01234567);
2411 });
2412 checkCCE(() -> { // array reference class
2413 int x = (int) vh.compareAndExchangeAcquire(Void.class, 0, 0x01234567, 0x01234567);
2414 });
2415 checkWMTE(() -> { // expected reference class
2416 int x = (int) vh.compareAndExchangeAcquire(array, 0, Void.class, 0x01234567);
2417 });
2418 checkWMTE(() -> { // actual reference class
2419 int x = (int) vh.compareAndExchangeAcquire(array, 0, 0x01234567, Void.class);
2420 });
2421 checkWMTE(() -> { // array primitive class
2422 int x = (int) vh.compareAndExchangeAcquire(0, 0, 0x01234567, 0x01234567);
2423 });
2424 checkWMTE(() -> { // index reference class
2425 int x = (int) vh.compareAndExchangeAcquire(array, Void.class, 0x01234567, 0x01234567);
2426 });
2427 // Incorrect return type
2428 checkWMTE(() -> { // reference class
2429 Void r = (Void) vh.compareAndExchangeAcquire(array, 0, 0x01234567, 0x01234567);
2430 });
2431 checkWMTE(() -> { // primitive class
2432 boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, 0x01234567, 0x01234567);
2433 });
2434 // Incorrect arity
2435 checkWMTE(() -> { // 0
2436 int x = (int) vh.compareAndExchangeAcquire();
2437 });
2438 checkWMTE(() -> { // >
2439 int x = (int) vh.compareAndExchangeAcquire(array, 0, 0x01234567, 0x01234567, Void.class);
2440 });
2441
2442
2443 // CompareAndExchangeRelease
2444 // Incorrect argument types
2445 checkNPE(() -> { // null receiver
2446 int x = (int) vh.compareAndExchangeRelease(null, 0, 0x01234567, 0x01234567);
2447 });
2448 checkCCE(() -> { // array reference class
2449 int x = (int) vh.compareAndExchangeRelease(Void.class, 0, 0x01234567, 0x01234567);
2450 });
2451 checkWMTE(() -> { // expected reference class
2452 int x = (int) vh.compareAndExchangeRelease(array, 0, Void.class, 0x01234567);
2453 });
2454 checkWMTE(() -> { // actual reference class
2455 int x = (int) vh.compareAndExchangeRelease(array, 0, 0x01234567, Void.class);
2456 });
2457 checkWMTE(() -> { // array primitive class
2458 int x = (int) vh.compareAndExchangeRelease(0, 0, 0x01234567, 0x01234567);
2459 });
2460 checkWMTE(() -> { // index reference class
2461 int x = (int) vh.compareAndExchangeRelease(array, Void.class, 0x01234567, 0x01234567);
2462 });
2463 // Incorrect return type
2464 checkWMTE(() -> { // reference class
2465 Void r = (Void) vh.compareAndExchangeRelease(array, 0, 0x01234567, 0x01234567);
2466 });
2467 checkWMTE(() -> { // primitive class
2468 boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, 0x01234567, 0x01234567);
2469 });
2470 // Incorrect arity
2471 checkWMTE(() -> { // 0
2472 int x = (int) vh.compareAndExchangeRelease();
2473 });
2474 checkWMTE(() -> { // >
2475 int x = (int) vh.compareAndExchangeRelease(array, 0, 0x01234567, 0x01234567, Void.class);
2476 });
2477
2478
2479 // GetAndSet
2480 // Incorrect argument types
2481 checkNPE(() -> { // null array
2482 int x = (int) vh.getAndSet(null, 0, 0x01234567);
2483 });
2484 checkCCE(() -> { // array reference class
2485 int x = (int) vh.getAndSet(Void.class, 0, 0x01234567);
2486 });
2487 checkWMTE(() -> { // value reference class
2488 int x = (int) vh.getAndSet(array, 0, Void.class);
2489 });
2490 checkWMTE(() -> { // reciarrayever primitive class
2491 int x = (int) vh.getAndSet(0, 0, 0x01234567);
2492 });
2493 checkWMTE(() -> { // index reference class
2494 int x = (int) vh.getAndSet(array, Void.class, 0x01234567);
2495 });
2496 // Incorrect return type
2497 checkWMTE(() -> { // reference class
2498 Void r = (Void) vh.getAndSet(array, 0, 0x01234567);
2499 });
2500 checkWMTE(() -> { // primitive class
2501 boolean x = (boolean) vh.getAndSet(array, 0, 0x01234567);
2502 });
2503 // Incorrect arity
2504 checkWMTE(() -> { // 0
2505 int x = (int) vh.getAndSet();
2506 });
2507 checkWMTE(() -> { // >
2508 int x = (int) vh.getAndSet(array, 0, 0x01234567, Void.class);
2509 });
2510
2511
2512 // GetAndSetAcquire
2513 // Incorrect argument types
2514 checkNPE(() -> { // null array
2515 int x = (int) vh.getAndSetAcquire(null, 0, 0x01234567);
2516 });
2517 checkCCE(() -> { // array reference class
2518 int x = (int) vh.getAndSetAcquire(Void.class, 0, 0x01234567);
2519 });
2520 checkWMTE(() -> { // value reference class
2521 int x = (int) vh.getAndSetAcquire(array, 0, Void.class);
2522 });
2523 checkWMTE(() -> { // reciarrayever primitive class
2524 int x = (int) vh.getAndSetAcquire(0, 0, 0x01234567);
2525 });
2526 checkWMTE(() -> { // index reference class
2527 int x = (int) vh.getAndSetAcquire(array, Void.class, 0x01234567);
2528 });
2529 // Incorrect return type
2530 checkWMTE(() -> { // reference class
2531 Void r = (Void) vh.getAndSetAcquire(array, 0, 0x01234567);
2532 });
2533 checkWMTE(() -> { // primitive class
2534 boolean x = (boolean) vh.getAndSetAcquire(array, 0, 0x01234567);
2535 });
2536 // Incorrect arity
2537 checkWMTE(() -> { // 0
2538 int x = (int) vh.getAndSetAcquire();
2539 });
2540 checkWMTE(() -> { // >
2541 int x = (int) vh.getAndSetAcquire(array, 0, 0x01234567, Void.class);
2542 });
2543
2544
2545 // GetAndSetRelease
2546 // Incorrect argument types
2547 checkNPE(() -> { // null array
2548 int x = (int) vh.getAndSetRelease(null, 0, 0x01234567);
2549 });
2550 checkCCE(() -> { // array reference class
2551 int x = (int) vh.getAndSetRelease(Void.class, 0, 0x01234567);
2552 });
2553 checkWMTE(() -> { // value reference class
2554 int x = (int) vh.getAndSetRelease(array, 0, Void.class);
2555 });
2556 checkWMTE(() -> { // reciarrayever primitive class
2557 int x = (int) vh.getAndSetRelease(0, 0, 0x01234567);
2558 });
2559 checkWMTE(() -> { // index reference class
2560 int x = (int) vh.getAndSetRelease(array, Void.class, 0x01234567);
2561 });
2562 // Incorrect return type
2563 checkWMTE(() -> { // reference class
2564 Void r = (Void) vh.getAndSetRelease(array, 0, 0x01234567);
2565 });
2566 checkWMTE(() -> { // primitive class
2567 boolean x = (boolean) vh.getAndSetRelease(array, 0, 0x01234567);
2568 });
2569 // Incorrect arity
2570 checkWMTE(() -> { // 0
2571 int x = (int) vh.getAndSetRelease();
2572 });
2573 checkWMTE(() -> { // >
2574 int x = (int) vh.getAndSetRelease(array, 0, 0x01234567, Void.class);
2575 });
2576
2577 // GetAndAdd
2578 // Incorrect argument types
2579 checkNPE(() -> { // null array
2580 int x = (int) vh.getAndAdd(null, 0, 0x01234567);
2581 });
2582 checkCCE(() -> { // array reference class
2583 int x = (int) vh.getAndAdd(Void.class, 0, 0x01234567);
2584 });
2585 checkWMTE(() -> { // value reference class
2586 int x = (int) vh.getAndAdd(array, 0, Void.class);
2587 });
2588 checkWMTE(() -> { // array primitive class
2589 int x = (int) vh.getAndAdd(0, 0, 0x01234567);
2590 });
2591 checkWMTE(() -> { // index reference class
2592 int x = (int) vh.getAndAdd(array, Void.class, 0x01234567);
2593 });
2594 // Incorrect return type
2595 checkWMTE(() -> { // reference class
2596 Void r = (Void) vh.getAndAdd(array, 0, 0x01234567);
2597 });
2598 checkWMTE(() -> { // primitive class
2599 boolean x = (boolean) vh.getAndAdd(array, 0, 0x01234567);
2600 });
2601 // Incorrect arity
2602 checkWMTE(() -> { // 0
2603 int x = (int) vh.getAndAdd();
2604 });
2605 checkWMTE(() -> { // >
2606 int x = (int) vh.getAndAdd(array, 0, 0x01234567, Void.class);
2607 });
2608
2609
2610 // GetAndAddAcquire
2611 // Incorrect argument types
2612 checkNPE(() -> { // null array
2613 int x = (int) vh.getAndAddAcquire(null, 0, 0x01234567);
2614 });
2615 checkCCE(() -> { // array reference class
2616 int x = (int) vh.getAndAddAcquire(Void.class, 0, 0x01234567);
2617 });
2618 checkWMTE(() -> { // value reference class
2619 int x = (int) vh.getAndAddAcquire(array, 0, Void.class);
2620 });
2621 checkWMTE(() -> { // array primitive class
2622 int x = (int) vh.getAndAddAcquire(0, 0, 0x01234567);
2623 });
2624 checkWMTE(() -> { // index reference class
2625 int x = (int) vh.getAndAddAcquire(array, Void.class, 0x01234567);
2626 });
2627 // Incorrect return type
2628 checkWMTE(() -> { // reference class
2629 Void r = (Void) vh.getAndAddAcquire(array, 0, 0x01234567);
2630 });
2631 checkWMTE(() -> { // primitive class
2632 boolean x = (boolean) vh.getAndAddAcquire(array, 0, 0x01234567);
2633 });
2634 // Incorrect arity
2635 checkWMTE(() -> { // 0
2636 int x = (int) vh.getAndAddAcquire();
2637 });
2638 checkWMTE(() -> { // >
2639 int x = (int) vh.getAndAddAcquire(array, 0, 0x01234567, Void.class);
2640 });
2641
2642
2643 // GetAndAddRelease
2644 // Incorrect argument types
2645 checkNPE(() -> { // null array
2646 int x = (int) vh.getAndAddRelease(null, 0, 0x01234567);
2647 });
2648 checkCCE(() -> { // array reference class
2649 int x = (int) vh.getAndAddRelease(Void.class, 0, 0x01234567);
2650 });
2651 checkWMTE(() -> { // value reference class
2652 int x = (int) vh.getAndAddRelease(array, 0, Void.class);
2653 });
2654 checkWMTE(() -> { // array primitive class
2655 int x = (int) vh.getAndAddRelease(0, 0, 0x01234567);
2656 });
2657 checkWMTE(() -> { // index reference class
2658 int x = (int) vh.getAndAddRelease(array, Void.class, 0x01234567);
2659 });
2660 // Incorrect return type
2661 checkWMTE(() -> { // reference class
2662 Void r = (Void) vh.getAndAddRelease(array, 0, 0x01234567);
2663 });
2664 checkWMTE(() -> { // primitive class
2665 boolean x = (boolean) vh.getAndAddRelease(array, 0, 0x01234567);
2666 });
2667 // Incorrect arity
2668 checkWMTE(() -> { // 0
2669 int x = (int) vh.getAndAddRelease();
2670 });
2671 checkWMTE(() -> { // >
2672 int x = (int) vh.getAndAddRelease(array, 0, 0x01234567, Void.class);
2673 });
2674
2675 // GetAndBitwiseOr
2676 // Incorrect argument types
2677 checkNPE(() -> { // null array
2678 int x = (int) vh.getAndBitwiseOr(null, 0, 0x01234567);
2679 });
2680 checkCCE(() -> { // array reference class
2681 int x = (int) vh.getAndBitwiseOr(Void.class, 0, 0x01234567);
2682 });
2683 checkWMTE(() -> { // value reference class
2684 int x = (int) vh.getAndBitwiseOr(array, 0, Void.class);
2685 });
2686 checkWMTE(() -> { // array primitive class
2687 int x = (int) vh.getAndBitwiseOr(0, 0, 0x01234567);
2688 });
2689 checkWMTE(() -> { // index reference class
2690 int x = (int) vh.getAndBitwiseOr(array, Void.class, 0x01234567);
2691 });
2692 // Incorrect return type
2693 checkWMTE(() -> { // reference class
2694 Void r = (Void) vh.getAndBitwiseOr(array, 0, 0x01234567);
2695 });
2696 checkWMTE(() -> { // primitive class
2697 boolean x = (boolean) vh.getAndBitwiseOr(array, 0, 0x01234567);
2698 });
2699 // Incorrect arity
2700 checkWMTE(() -> { // 0
2701 int x = (int) vh.getAndBitwiseOr();
2702 });
2703 checkWMTE(() -> { // >
2704 int x = (int) vh.getAndBitwiseOr(array, 0, 0x01234567, Void.class);
2705 });
2706
2707
2708 // GetAndBitwiseOrAcquire
2709 // Incorrect argument types
2710 checkNPE(() -> { // null array
2711 int x = (int) vh.getAndBitwiseOrAcquire(null, 0, 0x01234567);
2712 });
2713 checkCCE(() -> { // array reference class
2714 int x = (int) vh.getAndBitwiseOrAcquire(Void.class, 0, 0x01234567);
2715 });
2716 checkWMTE(() -> { // value reference class
2717 int x = (int) vh.getAndBitwiseOrAcquire(array, 0, Void.class);
2718 });
2719 checkWMTE(() -> { // array primitive class
2720 int x = (int) vh.getAndBitwiseOrAcquire(0, 0, 0x01234567);
2721 });
2722 checkWMTE(() -> { // index reference class
2723 int x = (int) vh.getAndBitwiseOrAcquire(array, Void.class, 0x01234567);
2724 });
2725 // Incorrect return type
2726 checkWMTE(() -> { // reference class
2727 Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, 0x01234567);
2728 });
2729 checkWMTE(() -> { // primitive class
2730 boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, 0x01234567);
2731 });
2732 // Incorrect arity
2733 checkWMTE(() -> { // 0
2734 int x = (int) vh.getAndBitwiseOrAcquire();
2735 });
2736 checkWMTE(() -> { // >
2737 int x = (int) vh.getAndBitwiseOrAcquire(array, 0, 0x01234567, Void.class);
2738 });
2739
2740
2741 // GetAndBitwiseOrRelease
2742 // Incorrect argument types
2743 checkNPE(() -> { // null array
2744 int x = (int) vh.getAndBitwiseOrRelease(null, 0, 0x01234567);
2745 });
2746 checkCCE(() -> { // array reference class
2747 int x = (int) vh.getAndBitwiseOrRelease(Void.class, 0, 0x01234567);
2748 });
2749 checkWMTE(() -> { // value reference class
2750 int x = (int) vh.getAndBitwiseOrRelease(array, 0, Void.class);
2751 });
2752 checkWMTE(() -> { // array primitive class
2753 int x = (int) vh.getAndBitwiseOrRelease(0, 0, 0x01234567);
2754 });
2755 checkWMTE(() -> { // index reference class
2756 int x = (int) vh.getAndBitwiseOrRelease(array, Void.class, 0x01234567);
2757 });
2758 // Incorrect return type
2759 checkWMTE(() -> { // reference class
2760 Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, 0x01234567);
2761 });
2762 checkWMTE(() -> { // primitive class
2763 boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, 0x01234567);
2764 });
2765 // Incorrect arity
2766 checkWMTE(() -> { // 0
2767 int x = (int) vh.getAndBitwiseOrRelease();
2768 });
2769 checkWMTE(() -> { // >
2770 int x = (int) vh.getAndBitwiseOrRelease(array, 0, 0x01234567, Void.class);
2771 });
2772
2773
2774 // GetAndBitwiseAnd
2775 // Incorrect argument types
2776 checkNPE(() -> { // null array
2777 int x = (int) vh.getAndBitwiseAnd(null, 0, 0x01234567);
2778 });
2779 checkCCE(() -> { // array reference class
2780 int x = (int) vh.getAndBitwiseAnd(Void.class, 0, 0x01234567);
2781 });
2782 checkWMTE(() -> { // value reference class
2783 int x = (int) vh.getAndBitwiseAnd(array, 0, Void.class);
2784 });
2785 checkWMTE(() -> { // array primitive class
2786 int x = (int) vh.getAndBitwiseAnd(0, 0, 0x01234567);
2787 });
2788 checkWMTE(() -> { // index reference class
2789 int x = (int) vh.getAndBitwiseAnd(array, Void.class, 0x01234567);
2790 });
2791 // Incorrect return type
2792 checkWMTE(() -> { // reference class
2793 Void r = (Void) vh.getAndBitwiseAnd(array, 0, 0x01234567);
2794 });
2795 checkWMTE(() -> { // primitive class
2796 boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, 0x01234567);
2797 });
2798 // Incorrect arity
2799 checkWMTE(() -> { // 0
2800 int x = (int) vh.getAndBitwiseAnd();
2801 });
2802 checkWMTE(() -> { // >
2803 int x = (int) vh.getAndBitwiseAnd(array, 0, 0x01234567, Void.class);
2804 });
2805
2806
2807 // GetAndBitwiseAndAcquire
2808 // Incorrect argument types
2809 checkNPE(() -> { // null array
2810 int x = (int) vh.getAndBitwiseAndAcquire(null, 0, 0x01234567);
2811 });
2812 checkCCE(() -> { // array reference class
2813 int x = (int) vh.getAndBitwiseAndAcquire(Void.class, 0, 0x01234567);
2814 });
2815 checkWMTE(() -> { // value reference class
2816 int x = (int) vh.getAndBitwiseAndAcquire(array, 0, Void.class);
2817 });
2818 checkWMTE(() -> { // array primitive class
2819 int x = (int) vh.getAndBitwiseAndAcquire(0, 0, 0x01234567);
2820 });
2821 checkWMTE(() -> { // index reference class
2822 int x = (int) vh.getAndBitwiseAndAcquire(array, Void.class, 0x01234567);
2823 });
2824 // Incorrect return type
2825 checkWMTE(() -> { // reference class
2826 Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, 0x01234567);
2827 });
2828 checkWMTE(() -> { // primitive class
2829 boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, 0x01234567);
2830 });
2831 // Incorrect arity
2832 checkWMTE(() -> { // 0
2833 int x = (int) vh.getAndBitwiseAndAcquire();
2834 });
2835 checkWMTE(() -> { // >
2836 int x = (int) vh.getAndBitwiseAndAcquire(array, 0, 0x01234567, Void.class);
2837 });
2838
2839
2840 // GetAndBitwiseAndRelease
2841 // Incorrect argument types
2842 checkNPE(() -> { // null array
2843 int x = (int) vh.getAndBitwiseAndRelease(null, 0, 0x01234567);
2844 });
2845 checkCCE(() -> { // array reference class
2846 int x = (int) vh.getAndBitwiseAndRelease(Void.class, 0, 0x01234567);
2847 });
2848 checkWMTE(() -> { // value reference class
2849 int x = (int) vh.getAndBitwiseAndRelease(array, 0, Void.class);
2850 });
2851 checkWMTE(() -> { // array primitive class
2852 int x = (int) vh.getAndBitwiseAndRelease(0, 0, 0x01234567);
2853 });
2854 checkWMTE(() -> { // index reference class
2855 int x = (int) vh.getAndBitwiseAndRelease(array, Void.class, 0x01234567);
2856 });
2857 // Incorrect return type
2858 checkWMTE(() -> { // reference class
2859 Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, 0x01234567);
2860 });
2861 checkWMTE(() -> { // primitive class
2862 boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, 0x01234567);
2863 });
2864 // Incorrect arity
2865 checkWMTE(() -> { // 0
2866 int x = (int) vh.getAndBitwiseAndRelease();
2867 });
2868 checkWMTE(() -> { // >
2869 int x = (int) vh.getAndBitwiseAndRelease(array, 0, 0x01234567, Void.class);
2870 });
2871
2872
2873 // GetAndBitwiseXor
2874 // Incorrect argument types
2875 checkNPE(() -> { // null array
2876 int x = (int) vh.getAndBitwiseXor(null, 0, 0x01234567);
2877 });
2878 checkCCE(() -> { // array reference class
2879 int x = (int) vh.getAndBitwiseXor(Void.class, 0, 0x01234567);
2880 });
2881 checkWMTE(() -> { // value reference class
2882 int x = (int) vh.getAndBitwiseXor(array, 0, Void.class);
2883 });
2884 checkWMTE(() -> { // array primitive class
2885 int x = (int) vh.getAndBitwiseXor(0, 0, 0x01234567);
2886 });
2887 checkWMTE(() -> { // index reference class
2888 int x = (int) vh.getAndBitwiseXor(array, Void.class, 0x01234567);
2889 });
2890 // Incorrect return type
2891 checkWMTE(() -> { // reference class
2892 Void r = (Void) vh.getAndBitwiseXor(array, 0, 0x01234567);
2893 });
2894 checkWMTE(() -> { // primitive class
2895 boolean x = (boolean) vh.getAndBitwiseXor(array, 0, 0x01234567);
2896 });
2897 // Incorrect arity
2898 checkWMTE(() -> { // 0
2899 int x = (int) vh.getAndBitwiseXor();
2900 });
2901 checkWMTE(() -> { // >
2902 int x = (int) vh.getAndBitwiseXor(array, 0, 0x01234567, Void.class);
2903 });
2904
2905
2906 // GetAndBitwiseXorAcquire
2907 // Incorrect argument types
2908 checkNPE(() -> { // null array
2909 int x = (int) vh.getAndBitwiseXorAcquire(null, 0, 0x01234567);
2910 });
2911 checkCCE(() -> { // array reference class
2912 int x = (int) vh.getAndBitwiseXorAcquire(Void.class, 0, 0x01234567);
2913 });
2914 checkWMTE(() -> { // value reference class
2915 int x = (int) vh.getAndBitwiseXorAcquire(array, 0, Void.class);
2916 });
2917 checkWMTE(() -> { // array primitive class
2918 int x = (int) vh.getAndBitwiseXorAcquire(0, 0, 0x01234567);
2919 });
2920 checkWMTE(() -> { // index reference class
2921 int x = (int) vh.getAndBitwiseXorAcquire(array, Void.class, 0x01234567);
2922 });
2923 // Incorrect return type
2924 checkWMTE(() -> { // reference class
2925 Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, 0x01234567);
2926 });
2927 checkWMTE(() -> { // primitive class
2928 boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, 0x01234567);
2929 });
2930 // Incorrect arity
2931 checkWMTE(() -> { // 0
2932 int x = (int) vh.getAndBitwiseXorAcquire();
2933 });
2934 checkWMTE(() -> { // >
2935 int x = (int) vh.getAndBitwiseXorAcquire(array, 0, 0x01234567, Void.class);
2936 });
2937
2938
2939 // GetAndBitwiseXorRelease
2940 // Incorrect argument types
2941 checkNPE(() -> { // null array
2942 int x = (int) vh.getAndBitwiseXorRelease(null, 0, 0x01234567);
2943 });
2944 checkCCE(() -> { // array reference class
2945 int x = (int) vh.getAndBitwiseXorRelease(Void.class, 0, 0x01234567);
2946 });
2947 checkWMTE(() -> { // value reference class
2948 int x = (int) vh.getAndBitwiseXorRelease(array, 0, Void.class);
2949 });
2950 checkWMTE(() -> { // array primitive class
2951 int x = (int) vh.getAndBitwiseXorRelease(0, 0, 0x01234567);
2952 });
2953 checkWMTE(() -> { // index reference class
2954 int x = (int) vh.getAndBitwiseXorRelease(array, Void.class, 0x01234567);
2955 });
2956 // Incorrect return type
2957 checkWMTE(() -> { // reference class
2958 Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, 0x01234567);
2959 });
2960 checkWMTE(() -> { // primitive class
2961 boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, 0x01234567);
2962 });
2963 // Incorrect arity
2964 checkWMTE(() -> { // 0
2965 int x = (int) vh.getAndBitwiseXorRelease();
2966 });
2967 checkWMTE(() -> { // >
2968 int x = (int) vh.getAndBitwiseXorRelease(array, 0, 0x01234567, Void.class);
2969 });
2970 }
2971
2972 static void testArrayWrongMethodType(Handles hs) throws Throwable {
2973 int[] array = new int[10];
2974 Arrays.fill(array, 0x01234567);
2975
2976 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
2977 // Incorrect argument types
2978 checkNPE(() -> { // null array
2979 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class)).
2980 invokeExact((int[]) null, 0);
2981 });
2982 hs.checkWMTEOrCCE(() -> { // array reference class
2983 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
2984 invokeExact(Void.class, 0);
2985 });
2986 checkWMTE(() -> { // array primitive class
2987 int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
2988 invokeExact(0, 0);
2989 });
2990 checkWMTE(() -> { // index reference class
2991 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class)).
2992 invokeExact(array, Void.class);
2993 });
2994 // Incorrect return type
2995 checkWMTE(() -> { // reference class
2996 Void x = (Void) hs.get(am, methodType(Void.class, int[].class, int.class)).
2997 invokeExact(array, 0);
2998 });
2999 checkWMTE(() -> { // primitive class
3000 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class)).
3001 invokeExact(array, 0);
3002 });
3003 // Incorrect arity
3004 checkWMTE(() -> { // 0
3005 int x = (int) hs.get(am, methodType(int.class)).
3006 invokeExact();
3007 });
3008 checkWMTE(() -> { // >
3009 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
3010 invokeExact(array, 0, Void.class);
3011 });
3012 }
3013
3014 for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
3015 // Incorrect argument types
3016 checkNPE(() -> { // null array
3017 hs.get(am, methodType(void.class, int[].class, int.class, int.class)).
3018 invokeExact((int[]) null, 0, 0x01234567);
3019 });
3020 hs.checkWMTEOrCCE(() -> { // array reference class
3021 hs.get(am, methodType(void.class, Class.class, int.class, int.class)).
3022 invokeExact(Void.class, 0, 0x01234567);
3023 });
3024 checkWMTE(() -> { // value reference class
3025 hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
3026 invokeExact(array, 0, Void.class);
3027 });
3028 checkWMTE(() -> { // receiver primitive class
3029 hs.get(am, methodType(void.class, int.class, int.class, int.class)).
3030 invokeExact(0, 0, 0x01234567);
3031 });
3032 checkWMTE(() -> { // index reference class
3033 hs.get(am, methodType(void.class, int[].class, Class.class, int.class)).
3034 invokeExact(array, Void.class, 0x01234567);
3035 });
3036 // Incorrect arity
3037 checkWMTE(() -> { // 0
3038 hs.get(am, methodType(void.class)).
3039 invokeExact();
3040 });
3041 checkWMTE(() -> { // >
3042 hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
3043 invokeExact(array, 0, 0x01234567, Void.class);
3044 });
3045 }
3046 for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
3047 // Incorrect argument types
3048 checkNPE(() -> { // null receiver
3049 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)).
3050 invokeExact((int[]) null, 0, 0x01234567, 0x01234567);
3051 });
3052 hs.checkWMTEOrCCE(() -> { // receiver reference class
3053 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class, int.class)).
3054 invokeExact(Void.class, 0, 0x01234567, 0x01234567);
3055 });
3056 checkWMTE(() -> { // expected reference class
3057 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, Class.class, int.class)).
3058 invokeExact(array, 0, Void.class, 0x01234567);
3059 });
3060 checkWMTE(() -> { // actual reference class
3061 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, Class.class)).
3062 invokeExact(array, 0, 0x01234567, Void.class);
3063 });
3064 checkWMTE(() -> { // receiver primitive class
3065 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, int.class, int.class)).
3066 invokeExact(0, 0, 0x01234567, 0x01234567);
3067 });
3068 checkWMTE(() -> { // index reference class
3069 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, Class.class, int.class, int.class)).
3070 invokeExact(array, Void.class, 0x01234567, 0x01234567);
3071 });
3072 // Incorrect arity
3073 checkWMTE(() -> { // 0
3074 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
3075 invokeExact();
3076 });
3077 checkWMTE(() -> { // >
3078 boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class, Class.class)).
3079 invokeExact(array, 0, 0x01234567, 0x01234567, Void.class);
3080 });
3081 }
3082
3083 for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
3084 // Incorrect argument types
3085 checkNPE(() -> { // null receiver
3086 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class)).
3087 invokeExact((int[]) null, 0, 0x01234567, 0x01234567);
3088 });
3089 hs.checkWMTEOrCCE(() -> { // array reference class
3090 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class, int.class)).
3091 invokeExact(Void.class, 0, 0x01234567, 0x01234567);
3092 });
3093 checkWMTE(() -> { // expected reference class
3094 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class, int.class)).
3095 invokeExact(array, 0, Void.class, 0x01234567);
3096 });
3097 checkWMTE(() -> { // actual reference class
3098 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
3099 invokeExact(array, 0, 0x01234567, Void.class);
3100 });
3101 checkWMTE(() -> { // array primitive class
3102 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class, int.class)).
3103 invokeExact(0, 0, 0x01234567, 0x01234567);
3104 });
3105 checkWMTE(() -> { // index reference class
3106 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class, int.class)).
3107 invokeExact(array, Void.class, 0x01234567, 0x01234567);
3108 });
3109 // Incorrect return type
3110 checkWMTE(() -> { // reference class
3111 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class, int.class)).
3112 invokeExact(array, 0, 0x01234567, 0x01234567);
3113 });
3114 checkWMTE(() -> { // primitive class
3115 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)).
3116 invokeExact(array, 0, 0x01234567, 0x01234567);
3117 });
3118 // Incorrect arity
3119 checkWMTE(() -> { // 0
3120 int x = (int) hs.get(am, methodType(int.class)).
3121 invokeExact();
3122 });
3123 checkWMTE(() -> { // >
3124 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class, Class.class)).
3125 invokeExact(array, 0, 0x01234567, 0x01234567, Void.class);
3126 });
3127 }
3128
3129 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
3130 // Incorrect argument types
3131 checkNPE(() -> { // null array
3132 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
3133 invokeExact((int[]) null, 0, 0x01234567);
3134 });
3135 hs.checkWMTEOrCCE(() -> { // array reference class
3136 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
3137 invokeExact(Void.class, 0, 0x01234567);
3138 });
3139 checkWMTE(() -> { // value reference class
3140 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
3141 invokeExact(array, 0, Void.class);
3142 });
3143 checkWMTE(() -> { // array primitive class
3144 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
3145 invokeExact(0, 0, 0x01234567);
3146 });
3147 checkWMTE(() -> { // index reference class
3148 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
3149 invokeExact(array, Void.class, 0x01234567);
3150 });
3151 // Incorrect return type
3152 checkWMTE(() -> { // reference class
3153 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
3154 invokeExact(array, 0, 0x01234567);
3155 });
3156 checkWMTE(() -> { // primitive class
3157 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
3158 invokeExact(array, 0, 0x01234567);
3159 });
3160 // Incorrect arity
3161 checkWMTE(() -> { // 0
3162 int x = (int) hs.get(am, methodType(int.class)).
3163 invokeExact();
3164 });
3165 checkWMTE(() -> { // >
3166 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
3167 invokeExact(array, 0, 0x01234567, Void.class);
3168 });
3169 }
3170
3171 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
3172 // Incorrect argument types
3173 checkNPE(() -> { // null array
3174 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
3175 invokeExact((int[]) null, 0, 0x01234567);
3176 });
3177 hs.checkWMTEOrCCE(() -> { // array reference class
3178 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
3179 invokeExact(Void.class, 0, 0x01234567);
3180 });
3181 checkWMTE(() -> { // value reference class
3182 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
3183 invokeExact(array, 0, Void.class);
3184 });
3185 checkWMTE(() -> { // array primitive class
3186 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
3187 invokeExact(0, 0, 0x01234567);
3188 });
3189 checkWMTE(() -> { // index reference class
3190 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
3191 invokeExact(array, Void.class, 0x01234567);
3192 });
3193 // Incorrect return type
3194 checkWMTE(() -> { // reference class
3195 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
3196 invokeExact(array, 0, 0x01234567);
3197 });
3198 checkWMTE(() -> { // primitive class
3199 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
3200 invokeExact(array, 0, 0x01234567);
3201 });
3202 // Incorrect arity
3203 checkWMTE(() -> { // 0
3204 int x = (int) hs.get(am, methodType(int.class)).
3205 invokeExact();
3206 });
3207 checkWMTE(() -> { // >
3208 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
3209 invokeExact(array, 0, 0x01234567, Void.class);
3210 });
3211 }
3212
3213 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) {
3214 // Incorrect argument types
3215 checkNPE(() -> { // null array
3216 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
3217 invokeExact((int[]) null, 0, 0x01234567);
3218 });
3219 hs.checkWMTEOrCCE(() -> { // array reference class
3220 int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
3221 invokeExact(Void.class, 0, 0x01234567);
3222 });
3223 checkWMTE(() -> { // value reference class
3224 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
3225 invokeExact(array, 0, Void.class);
3226 });
3227 checkWMTE(() -> { // array primitive class
3228 int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
3229 invokeExact(0, 0, 0x01234567);
3230 });
3231 checkWMTE(() -> { // index reference class
3232 int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
3233 invokeExact(array, Void.class, 0x01234567);
3234 });
3235 // Incorrect return type
3236 checkWMTE(() -> { // reference class
3237 Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
3238 invokeExact(array, 0, 0x01234567);
3239 });
3240 checkWMTE(() -> { // primitive class
3241 boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
3242 invokeExact(array, 0, 0x01234567);
3243 });
3244 // Incorrect arity
3245 checkWMTE(() -> { // 0
3246 int x = (int) hs.get(am, methodType(int.class)).
3247 invokeExact();
3248 });
3249 checkWMTE(() -> { // >
3250 int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
3251 invokeExact(array, 0, 0x01234567, Void.class);
3252 });
3253 }
3254 }
3255 }
--- EOF ---