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