1 /*
   2  * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 // -- This file was mechanically generated: Do not edit! -- //
  25 
  26 /*
  27  * @test
  28  * @comment Set CompileThresholdScaling to 0.1 so that the warmup loop sets to 2000 iterations
  29  *          to hit compilation thresholds
  30  * @run testng/othervm -Diters=2000 -XX:CompileThresholdScaling=0.1 VarHandleTestMethodHandleAccessBoolean
  31  */
  32 
  33 import org.testng.annotations.BeforeClass;
  34 import org.testng.annotations.DataProvider;
  35 import org.testng.annotations.Test;
  36 
  37 import java.lang.invoke.MethodHandle;
  38 import java.lang.invoke.MethodHandles;
  39 import java.lang.invoke.VarHandle;
  40 import java.util.ArrayList;
  41 import java.util.Arrays;
  42 import java.util.List;
  43 
  44 import static org.testng.Assert.*;
  45 
  46 public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest {
  47     static final boolean static_final_v = true;
  48 
  49     static boolean static_v;
  50 
  51     final boolean final_v = true;
  52 
  53     boolean v;
  54 
  55     VarHandle vhFinalField;
  56 
  57     VarHandle vhField;
  58 
  59     VarHandle vhStaticField;
  60 
  61     VarHandle vhStaticFinalField;
  62 
  63     VarHandle vhArray;
  64 
  65     @BeforeClass
  66     public void setup() throws Exception {
  67         vhFinalField = MethodHandles.lookup().findVarHandle(
  68                 VarHandleTestMethodHandleAccessBoolean.class, "final_v", boolean.class);
  69 
  70         vhField = MethodHandles.lookup().findVarHandle(
  71                 VarHandleTestMethodHandleAccessBoolean.class, "v", boolean.class);
  72 
  73         vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
  74             VarHandleTestMethodHandleAccessBoolean.class, "static_final_v", boolean.class);
  75 
  76         vhStaticField = MethodHandles.lookup().findStaticVarHandle(
  77             VarHandleTestMethodHandleAccessBoolean.class, "static_v", boolean.class);
  78 
  79         vhArray = MethodHandles.arrayElementVarHandle(boolean[].class);
  80     }
  81 
  82 
  83     @DataProvider
  84     public Object[][] accessTestCaseProvider() throws Exception {
  85         List<AccessTestCase<?>> cases = new ArrayList<>();
  86 
  87         for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
  88             cases.add(new MethodHandleAccessTestCase("Instance field",
  89                                                      vhField, f, hs -> testInstanceField(this, hs)));
  90             cases.add(new MethodHandleAccessTestCase("Instance field unsupported",
  91                                                      vhField, f, hs -> testInstanceFieldUnsupported(this, hs),
  92                                                      false));
  93 
  94             cases.add(new MethodHandleAccessTestCase("Static field",
  95                                                      vhStaticField, f, VarHandleTestMethodHandleAccessBoolean::testStaticField));
  96             cases.add(new MethodHandleAccessTestCase("Static field unsupported",
  97                                                      vhStaticField, f, VarHandleTestMethodHandleAccessBoolean::testStaticFieldUnsupported,
  98                                                      false));
  99 
 100             cases.add(new MethodHandleAccessTestCase("Array",
 101                                                      vhArray, f, VarHandleTestMethodHandleAccessBoolean::testArray));
 102             cases.add(new MethodHandleAccessTestCase("Array unsupported",
 103                                                      vhArray, f, VarHandleTestMethodHandleAccessBoolean::testArrayUnsupported,
 104                                                      false));
 105             cases.add(new MethodHandleAccessTestCase("Array index out of bounds",
 106                                                      vhArray, f, VarHandleTestMethodHandleAccessBoolean::testArrayIndexOutOfBounds,
 107                                                      false));
 108         }
 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 testInstanceField(VarHandleTestMethodHandleAccessBoolean recv, Handles hs) throws Throwable {
 127         // Plain
 128         {
 129             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 130             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 131             assertEquals(x, true, "set boolean value");
 132         }
 133 
 134 
 135         // Volatile
 136         {
 137             hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, false);
 138             boolean x = (boolean) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
 139             assertEquals(x, false, "setVolatile boolean value");
 140         }
 141 
 142         // Lazy
 143         {
 144             hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, true);
 145             boolean x = (boolean) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
 146             assertEquals(x, true, "setRelease boolean value");
 147         }
 148 
 149         // Opaque
 150         {
 151             hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, false);
 152             boolean x = (boolean) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
 153             assertEquals(x, false, "setOpaque boolean value");
 154         }
 155 
 156         hs.get(TestAccessMode.SET).invokeExact(recv, true);
 157 
 158         // Compare
 159         {
 160             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, true, false);
 161             assertEquals(r, true, "success compareAndSet boolean");
 162             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 163             assertEquals(x, false, "success compareAndSet boolean value");
 164         }
 165 
 166         {
 167             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, true, false);
 168             assertEquals(r, false, "failing compareAndSet boolean");
 169             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 170             assertEquals(x, false, "failing compareAndSet boolean value");
 171         }
 172 
 173         {
 174             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(recv, false, true);
 175             assertEquals(r, false, "success compareAndExchange boolean");
 176             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 177             assertEquals(x, true, "success compareAndExchange boolean value");
 178         }
 179 
 180         {
 181             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(recv, false, false);
 182             assertEquals(r, true, "failing compareAndExchange boolean");
 183             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 184             assertEquals(x, true, "failing compareAndExchange boolean value");
 185         }
 186 
 187         {
 188             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, true, false);
 189             assertEquals(r, true, "success compareAndExchangeAcquire boolean");
 190             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 191             assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
 192         }
 193 
 194         {
 195             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, true, false);
 196             assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
 197             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 198             assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
 199         }
 200 
 201         {
 202             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, false, true);
 203             assertEquals(r, false, "success compareAndExchangeRelease boolean");
 204             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 205             assertEquals(x, true, "success compareAndExchangeRelease boolean value");
 206         }
 207 
 208         {
 209             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, false, false);
 210             assertEquals(r, true, "failing compareAndExchangeRelease boolean");
 211             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 212             assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
 213         }
 214 
 215         {
 216             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN);
 217             boolean success = false;
 218             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 219                 success = (boolean) mh.invokeExact(recv, true, false);
 220                 if (!success) weakDelay();
 221             }
 222             assertEquals(success, true, "success weakCompareAndSetPlain boolean");
 223             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 224             assertEquals(x, false, "success weakCompareAndSetPlain boolean value");
 225         }
 226 
 227         {
 228             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, true, false);
 229             assertEquals(success, false, "failing weakCompareAndSetPlain boolean");
 230             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 231             assertEquals(x, false, "failing weakCompareAndSetPlain boolean value");
 232         }
 233 
 234         {
 235             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE);
 236             boolean success = false;
 237             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 238                 success = (boolean) mh.invokeExact(recv, false, true);
 239                 if (!success) weakDelay();
 240             }
 241             assertEquals(success, true, "success weakCompareAndSetAcquire boolean");
 242             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 243             assertEquals(x, true, "success weakCompareAndSetAcquire boolean");
 244         }
 245 
 246         {
 247             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, false, false);
 248             assertEquals(success, false, "failing weakCompareAndSetAcquire boolean");
 249             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 250             assertEquals(x, true, "failing weakCompareAndSetAcquire boolean value");
 251         }
 252 
 253         {
 254             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE);
 255             boolean success = false;
 256             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 257                 success = (boolean) mh.invokeExact(recv, true, false);
 258                 if (!success) weakDelay();
 259             }
 260             assertEquals(success, true, "success weakCompareAndSetRelease boolean");
 261             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 262             assertEquals(x, false, "success weakCompareAndSetRelease boolean");
 263         }
 264 
 265         {
 266             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, true, false);
 267             assertEquals(success, false, "failing weakCompareAndSetRelease boolean");
 268             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 269             assertEquals(x, false, "failing weakCompareAndSetRelease boolean value");
 270         }
 271 
 272         {
 273             boolean success = false;
 274             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET);
 275             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 276                 success = (boolean) mh.invokeExact(recv, false, true);
 277                 if (!success) weakDelay();
 278             }
 279             assertEquals(success, true, "success weakCompareAndSet boolean");
 280             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 281             assertEquals(x, true, "success weakCompareAndSet boolean");
 282         }
 283 
 284         {
 285             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, false, false);
 286             assertEquals(success, false, "failing weakCompareAndSet boolean");
 287             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 288             assertEquals(x, true, "failing weakCompareAndSet boolean value");
 289         }
 290 
 291         // Compare set and get
 292         {
 293             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, false);
 294             assertEquals(o, true, "getAndSet boolean");
 295             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 296             assertEquals(x, false, "getAndSet boolean value");
 297         }
 298 
 299 
 300         // get and bitwise or
 301         {
 302             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 303 
 304             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, false);
 305             assertEquals(o, true, "getAndBitwiseOr boolean");
 306             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 307             assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value");
 308         }
 309 
 310         {
 311             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 312 
 313             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, false);
 314             assertEquals(o, true, "getAndBitwiseOrAcquire boolean");
 315             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 316             assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value");
 317         }
 318 
 319         {
 320             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 321 
 322             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, false);
 323             assertEquals(o, true, "getAndBitwiseOrRelease boolean");
 324             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 325             assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value");
 326         }
 327 
 328         // get and bitwise and
 329         {
 330             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 331 
 332             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, false);
 333             assertEquals(o, true, "getAndBitwiseAnd boolean");
 334             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 335             assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value");
 336         }
 337 
 338         {
 339             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 340 
 341             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, false);
 342             assertEquals(o, true, "getAndBitwiseAndAcquire boolean");
 343             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 344             assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value");
 345         }
 346 
 347         {
 348             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 349 
 350             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, false);
 351             assertEquals(o, true, "getAndBitwiseAndRelease boolean");
 352             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 353             assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value");
 354         }
 355 
 356         // get and bitwise xor
 357         {
 358             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 359 
 360             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, false);
 361             assertEquals(o, true, "getAndBitwiseXor boolean");
 362             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 363             assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value");
 364         }
 365 
 366         {
 367             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 368 
 369             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, false);
 370             assertEquals(o, true, "getAndBitwiseXorAcquire boolean");
 371             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 372             assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value");
 373         }
 374 
 375         {
 376             hs.get(TestAccessMode.SET).invokeExact(recv, true);
 377 
 378             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, false);
 379             assertEquals(o, true, "getAndBitwiseXorRelease boolean");
 380             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
 381             assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value");
 382         }
 383     }
 384 
 385     static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessBoolean recv, Handles hs) throws Throwable {
 386 
 387         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
 388             checkUOE(am, () -> {
 389                 boolean r = (boolean) hs.get(am).invokeExact(recv, true);
 390             });
 391         }
 392 
 393     }
 394 
 395 
 396     static void testStaticField(Handles hs) throws Throwable {
 397         // Plain
 398         {
 399             hs.get(TestAccessMode.SET).invokeExact(true);
 400             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 401             assertEquals(x, true, "set boolean value");
 402         }
 403 
 404 
 405         // Volatile
 406         {
 407             hs.get(TestAccessMode.SET_VOLATILE).invokeExact(false);
 408             boolean x = (boolean) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
 409             assertEquals(x, false, "setVolatile boolean value");
 410         }
 411 
 412         // Lazy
 413         {
 414             hs.get(TestAccessMode.SET_RELEASE).invokeExact(true);
 415             boolean x = (boolean) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
 416             assertEquals(x, true, "setRelease boolean value");
 417         }
 418 
 419         // Opaque
 420         {
 421             hs.get(TestAccessMode.SET_OPAQUE).invokeExact(false);
 422             boolean x = (boolean) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
 423             assertEquals(x, false, "setOpaque boolean value");
 424         }
 425 
 426         hs.get(TestAccessMode.SET).invokeExact(true);
 427 
 428         // Compare
 429         {
 430             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(true, false);
 431             assertEquals(r, true, "success compareAndSet boolean");
 432             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 433             assertEquals(x, false, "success compareAndSet boolean value");
 434         }
 435 
 436         {
 437             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(true, false);
 438             assertEquals(r, false, "failing compareAndSet boolean");
 439             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 440             assertEquals(x, false, "failing compareAndSet boolean value");
 441         }
 442 
 443         {
 444             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(false, true);
 445             assertEquals(r, false, "success compareAndExchange boolean");
 446             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 447             assertEquals(x, true, "success compareAndExchange boolean value");
 448         }
 449 
 450         {
 451             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(false, false);
 452             assertEquals(r, true, "failing compareAndExchange boolean");
 453             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 454             assertEquals(x, true, "failing compareAndExchange boolean value");
 455         }
 456 
 457         {
 458             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(true, false);
 459             assertEquals(r, true, "success compareAndExchangeAcquire boolean");
 460             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 461             assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
 462         }
 463 
 464         {
 465             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(true, false);
 466             assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
 467             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 468             assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
 469         }
 470 
 471         {
 472             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(false, true);
 473             assertEquals(r, false, "success compareAndExchangeRelease boolean");
 474             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 475             assertEquals(x, true, "success compareAndExchangeRelease boolean value");
 476         }
 477 
 478         {
 479             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(false, false);
 480             assertEquals(r, true, "failing compareAndExchangeRelease boolean");
 481             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 482             assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
 483         }
 484 
 485         {
 486             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN);
 487             boolean success = false;
 488             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 489                 success = (boolean) mh.invokeExact(true, false);
 490                 if (!success) weakDelay();
 491             }
 492             assertEquals(success, true, "success weakCompareAndSetPlain boolean");
 493             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 494             assertEquals(x, false, "success weakCompareAndSetPlain boolean value");
 495         }
 496 
 497         {
 498             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(true, false);
 499             assertEquals(success, false, "failing weakCompareAndSetPlain boolean");
 500             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 501             assertEquals(x, false, "failing weakCompareAndSetPlain boolean value");
 502         }
 503 
 504         {
 505             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE);
 506             boolean success = false;
 507             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 508                 success = (boolean) mh.invokeExact(false, true);
 509                 if (!success) weakDelay();
 510             }
 511             assertEquals(success, true, "success weakCompareAndSetAcquire boolean");
 512             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 513             assertEquals(x, true, "success weakCompareAndSetAcquire boolean");
 514         }
 515 
 516         {
 517             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE);
 518             boolean success = (boolean) mh.invokeExact(false, false);
 519             assertEquals(success, false, "failing weakCompareAndSetAcquire boolean");
 520             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 521             assertEquals(x, true, "failing weakCompareAndSetAcquire boolean value");
 522         }
 523 
 524         {
 525             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE);
 526             boolean success = false;
 527             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 528                 success = (boolean) mh.invokeExact(true, false);
 529                 if (!success) weakDelay();
 530             }
 531             assertEquals(success, true, "success weakCompareAndSetRelease boolean");
 532             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 533             assertEquals(x, false, "success weakCompareAndSetRelease boolean");
 534         }
 535 
 536         {
 537             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(true, false);
 538             assertEquals(success, false, "failing weakCompareAndSetRelease boolean");
 539             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 540             assertEquals(x, false, "failing weakCompareAndSetRelease boolean value");
 541         }
 542 
 543         {
 544             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET);
 545             boolean success = false;
 546             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 547                 success = (boolean) mh.invokeExact(false, true);
 548                 if (!success) weakDelay();
 549             }
 550             assertEquals(success, true, "success weakCompareAndSet boolean");
 551             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 552             assertEquals(x, true, "success weakCompareAndSet boolean");
 553         }
 554 
 555         {
 556             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(false, false);
 557             assertEquals(success, false, "failing weakCompareAndSet boolean");
 558             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 559             assertEquals(x, true, "failing weakCompareAndSetRe boolean value");
 560         }
 561 
 562         // Compare set and get
 563         {
 564             hs.get(TestAccessMode.SET).invokeExact(true);
 565 
 566             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(false);
 567             assertEquals(o, true, "getAndSet boolean");
 568             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 569             assertEquals(x, false, "getAndSet boolean value");
 570         }
 571 
 572         // Compare set and get
 573         {
 574             hs.get(TestAccessMode.SET).invokeExact(true);
 575 
 576             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(false);
 577             assertEquals(o, true, "getAndSetAcquire boolean");
 578             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 579             assertEquals(x, false, "getAndSetAcquire boolean value");
 580         }
 581 
 582         // Compare set and get
 583         {
 584             hs.get(TestAccessMode.SET).invokeExact(true);
 585 
 586             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(false);
 587             assertEquals(o, true, "getAndSetRelease boolean");
 588             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 589             assertEquals(x, false, "getAndSetRelease boolean value");
 590         }
 591 
 592 
 593         // get and bitwise or
 594         {
 595             hs.get(TestAccessMode.SET).invokeExact(true);
 596 
 597             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(false);
 598             assertEquals(o, true, "getAndBitwiseOr boolean");
 599             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 600             assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value");
 601         }
 602 
 603         {
 604             hs.get(TestAccessMode.SET).invokeExact(true);
 605 
 606             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(false);
 607             assertEquals(o, true, "getAndBitwiseOrAcquire boolean");
 608             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 609             assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value");
 610         }
 611 
 612         {
 613             hs.get(TestAccessMode.SET).invokeExact(true);
 614 
 615             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(false);
 616             assertEquals(o, true, "getAndBitwiseOrRelease boolean");
 617             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 618             assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value");
 619         }
 620 
 621         // get and bitwise and
 622         {
 623             hs.get(TestAccessMode.SET).invokeExact(true);
 624 
 625             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(false);
 626             assertEquals(o, true, "getAndBitwiseAnd boolean");
 627             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 628             assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value");
 629         }
 630 
 631         {
 632             hs.get(TestAccessMode.SET).invokeExact(true);
 633 
 634             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(false);
 635             assertEquals(o, true, "getAndBitwiseAndAcquire boolean");
 636             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 637             assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value");
 638         }
 639 
 640         {
 641             hs.get(TestAccessMode.SET).invokeExact(true);
 642 
 643             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(false);
 644             assertEquals(o, true, "getAndBitwiseAndRelease boolean");
 645             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 646             assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value");
 647         }
 648 
 649         // get and bitwise xor
 650         {
 651             hs.get(TestAccessMode.SET).invokeExact(true);
 652 
 653             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(false);
 654             assertEquals(o, true, "getAndBitwiseXor boolean");
 655             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 656             assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value");
 657         }
 658 
 659         {
 660             hs.get(TestAccessMode.SET).invokeExact(true);
 661 
 662             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(false);
 663             assertEquals(o, true, "getAndBitwiseXorAcquire boolean");
 664             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 665             assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value");
 666         }
 667 
 668         {
 669             hs.get(TestAccessMode.SET).invokeExact(true);
 670 
 671             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(false);
 672             assertEquals(o, true, "getAndBitwiseXorRelease boolean");
 673             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
 674             assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value");
 675         }
 676     }
 677 
 678     static void testStaticFieldUnsupported(Handles hs) throws Throwable {
 679 
 680         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
 681             checkUOE(am, () -> {
 682                 boolean r = (boolean) hs.get(am).invokeExact(true);
 683             });
 684         }
 685 
 686     }
 687 
 688 
 689     static void testArray(Handles hs) throws Throwable {
 690         boolean[] array = new boolean[10];
 691 
 692         for (int i = 0; i < array.length; i++) {
 693             // Plain
 694             {
 695                 hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 696                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 697                 assertEquals(x, true, "get boolean value");
 698             }
 699 
 700 
 701             // Volatile
 702             {
 703                 hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, false);
 704                 boolean x = (boolean) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
 705                 assertEquals(x, false, "setVolatile boolean value");
 706             }
 707 
 708             // Lazy
 709             {
 710                 hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, true);
 711                 boolean x = (boolean) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
 712                 assertEquals(x, true, "setRelease boolean value");
 713             }
 714 
 715             // Opaque
 716             {
 717                 hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, false);
 718                 boolean x = (boolean) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
 719                 assertEquals(x, false, "setOpaque boolean value");
 720             }
 721 
 722             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 723 
 724             // Compare
 725             {
 726                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, true, false);
 727                 assertEquals(r, true, "success compareAndSet boolean");
 728                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 729                 assertEquals(x, false, "success compareAndSet boolean value");
 730             }
 731 
 732             {
 733                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, true, false);
 734                 assertEquals(r, false, "failing compareAndSet boolean");
 735                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 736                 assertEquals(x, false, "failing compareAndSet boolean value");
 737             }
 738 
 739             {
 740                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(array, i, false, true);
 741                 assertEquals(r, false, "success compareAndExchange boolean");
 742                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 743                 assertEquals(x, true, "success compareAndExchange boolean value");
 744             }
 745 
 746             {
 747                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(array, i, false, false);
 748                 assertEquals(r, true, "failing compareAndExchange boolean");
 749                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 750                 assertEquals(x, true, "failing compareAndExchange boolean value");
 751             }
 752 
 753             {
 754                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, true, false);
 755                 assertEquals(r, true, "success compareAndExchangeAcquire boolean");
 756                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 757                 assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
 758             }
 759 
 760             {
 761                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, true, false);
 762                 assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
 763                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 764                 assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
 765             }
 766 
 767             {
 768                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, false, true);
 769                 assertEquals(r, false, "success compareAndExchangeRelease boolean");
 770                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 771                 assertEquals(x, true, "success compareAndExchangeRelease boolean value");
 772             }
 773 
 774             {
 775                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, false, false);
 776                 assertEquals(r, true, "failing compareAndExchangeRelease boolean");
 777                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 778                 assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
 779             }
 780 
 781             {
 782                 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN);
 783                 boolean success = false;
 784                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 785                     success = (boolean) mh.invokeExact(array, i, true, false);
 786                     if (!success) weakDelay();
 787                 }
 788                 assertEquals(success, true, "success weakCompareAndSetPlain boolean");
 789                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 790                 assertEquals(x, false, "success weakCompareAndSetPlain boolean value");
 791             }
 792 
 793             {
 794                 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, true, false);
 795                 assertEquals(success, false, "failing weakCompareAndSetPlain boolean");
 796                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 797                 assertEquals(x, false, "failing weakCompareAndSetPlain boolean value");
 798             }
 799 
 800             {
 801                 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE);
 802                 boolean success = false;
 803                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 804                     success = (boolean) mh.invokeExact(array, i, false, true);
 805                     if (!success) weakDelay();
 806                 }
 807                 assertEquals(success, true, "success weakCompareAndSetAcquire boolean");
 808                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 809                 assertEquals(x, true, "success weakCompareAndSetAcquire boolean");
 810             }
 811 
 812             {
 813                 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, false, false);
 814                 assertEquals(success, false, "failing weakCompareAndSetAcquire boolean");
 815                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 816                 assertEquals(x, true, "failing weakCompareAndSetAcquire boolean value");
 817             }
 818 
 819             {
 820                 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE);
 821                 boolean success = false;
 822                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 823                     success = (boolean) mh.invokeExact(array, i, true, false);
 824                     if (!success) weakDelay();
 825                 }
 826                 assertEquals(success, true, "success weakCompareAndSetRelease boolean");
 827                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 828                 assertEquals(x, false, "success weakCompareAndSetRelease boolean");
 829             }
 830 
 831             {
 832                 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, true, false);
 833                 assertEquals(success, false, "failing weakCompareAndSetAcquire boolean");
 834                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 835                 assertEquals(x, false, "failing weakCompareAndSetAcquire boolean value");
 836             }
 837 
 838             {
 839                 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET);
 840                 boolean success = false;
 841                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 842                     success = (boolean) mh.invokeExact(array, i, false, true);
 843                     if (!success) weakDelay();
 844                 }
 845                 assertEquals(success, true, "success weakCompareAndSet boolean");
 846                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 847                 assertEquals(x, true, "success weakCompareAndSet boolean");
 848             }
 849 
 850             {
 851                 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, false, false);
 852                 assertEquals(success, false, "failing weakCompareAndSet boolean");
 853                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 854                 assertEquals(x, true, "failing weakCompareAndSet boolean value");
 855             }
 856 
 857             // Compare set and get
 858             {
 859                 hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 860 
 861                 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, false);
 862                 assertEquals(o, true, "getAndSet boolean");
 863                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 864                 assertEquals(x, false, "getAndSet boolean value");
 865             }
 866 
 867             {
 868                 hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 869 
 870                 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, false);
 871                 assertEquals(o, true, "getAndSetAcquire boolean");
 872                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 873                 assertEquals(x, false, "getAndSetAcquire boolean value");
 874             }
 875 
 876             {
 877                 hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 878 
 879                 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, false);
 880                 assertEquals(o, true, "getAndSetRelease boolean");
 881                 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 882                 assertEquals(x, false, "getAndSetRelease boolean value");
 883             }
 884 
 885 
 886         // get and bitwise or
 887         {
 888             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 889 
 890             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, false);
 891             assertEquals(o, true, "getAndBitwiseOr boolean");
 892             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 893             assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value");
 894         }
 895 
 896         {
 897             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 898 
 899             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, false);
 900             assertEquals(o, true, "getAndBitwiseOrAcquire boolean");
 901             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 902             assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value");
 903         }
 904 
 905         {
 906             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 907 
 908             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, false);
 909             assertEquals(o, true, "getAndBitwiseOrRelease boolean");
 910             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 911             assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value");
 912         }
 913 
 914         // get and bitwise and
 915         {
 916             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 917 
 918             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, false);
 919             assertEquals(o, true, "getAndBitwiseAnd boolean");
 920             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 921             assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value");
 922         }
 923 
 924         {
 925             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 926 
 927             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, false);
 928             assertEquals(o, true, "getAndBitwiseAndAcquire boolean");
 929             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 930             assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value");
 931         }
 932 
 933         {
 934             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 935 
 936             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, false);
 937             assertEquals(o, true, "getAndBitwiseAndRelease boolean");
 938             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 939             assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value");
 940         }
 941 
 942         // get and bitwise xor
 943         {
 944             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 945 
 946             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, false);
 947             assertEquals(o, true, "getAndBitwiseXor boolean");
 948             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 949             assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value");
 950         }
 951 
 952         {
 953             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 954 
 955             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, false);
 956             assertEquals(o, true, "getAndBitwiseXorAcquire boolean");
 957             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 958             assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value");
 959         }
 960 
 961         {
 962             hs.get(TestAccessMode.SET).invokeExact(array, i, true);
 963 
 964             boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, false);
 965             assertEquals(o, true, "getAndBitwiseXorRelease boolean");
 966             boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
 967             assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value");
 968         }
 969         }
 970     }
 971 
 972     static void testArrayUnsupported(Handles hs) throws Throwable {
 973         boolean[] array = new boolean[10];
 974 
 975         final int i = 0;
 976 
 977         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
 978             checkUOE(am, () -> {
 979                 boolean o = (boolean) hs.get(am).invokeExact(array, i, true);
 980             });
 981         }
 982 
 983     }
 984 
 985     static void testArrayIndexOutOfBounds(Handles hs) throws Throwable {
 986         boolean[] array = new boolean[10];
 987 
 988         for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
 989             final int ci = i;
 990 
 991             for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
 992                 checkAIOOBE(am, () -> {
 993                     boolean x = (boolean) hs.get(am).invokeExact(array, ci);
 994                 });
 995             }
 996 
 997             for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
 998                 checkAIOOBE(am, () -> {
 999                     hs.get(am).invokeExact(array, ci, true);
1000                 });
1001             }
1002 
1003             for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
1004                 checkAIOOBE(am, () -> {
1005                     boolean r = (boolean) hs.get(am).invokeExact(array, ci, true, false);
1006                 });
1007             }
1008 
1009             for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
1010                 checkAIOOBE(am, () -> {
1011                     boolean r = (boolean) hs.get(am).invokeExact(array, ci, false, true);
1012                 });
1013             }
1014 
1015             for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
1016                 checkAIOOBE(am, () -> {
1017                     boolean o = (boolean) hs.get(am).invokeExact(array, ci, true);
1018                 });
1019             }
1020 
1021 
1022             for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) {
1023                 checkAIOOBE(am, () -> {
1024                     boolean o = (boolean) hs.get(am).invokeExact(array, ci, false);
1025                 });
1026             }
1027         }
1028     }
1029 }
1030