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