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