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