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