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