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