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 VarHandleTestMethodHandleAccessChar
  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 VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest {
  47     static final char static_final_v = '\u0123';
  48 
  49     static char static_v;
  50 
  51     final char final_v = '\u0123';
  52 
  53     char 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                 VarHandleTestMethodHandleAccessChar.class, "final_v", char.class);
  69 
  70         vhField = MethodHandles.lookup().findVarHandle(
  71                 VarHandleTestMethodHandleAccessChar.class, "v", char.class);
  72 
  73         vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
  74             VarHandleTestMethodHandleAccessChar.class, "static_final_v", char.class);
  75 
  76         vhStaticField = MethodHandles.lookup().findStaticVarHandle(
  77             VarHandleTestMethodHandleAccessChar.class, "static_v", char.class);
  78 
  79         vhArray = MethodHandles.arrayElementVarHandle(char[].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, VarHandleTestMethodHandleAccessChar::testStaticField));
  96             cases.add(new MethodHandleAccessTestCase("Static field unsupported",
  97                                                      vhStaticField, f, VarHandleTestMethodHandleAccessChar::testStaticFieldUnsupported,
  98                                                      false));
  99 
 100             cases.add(new MethodHandleAccessTestCase("Array",
 101                                                      vhArray, f, VarHandleTestMethodHandleAccessChar::testArray));
 102             cases.add(new MethodHandleAccessTestCase("Array unsupported",
 103                                                      vhArray, f, VarHandleTestMethodHandleAccessChar::testArrayUnsupported,
 104                                                      false));
 105             cases.add(new MethodHandleAccessTestCase("Array index out of bounds",
 106                                                      vhArray, f, VarHandleTestMethodHandleAccessChar::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(VarHandleTestMethodHandleAccessChar recv, Handles hs) throws Throwable {
 127         // Plain
 128         {
 129             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 130             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 131             assertEquals(x, '\u0123', "set char value");
 132         }
 133 
 134 
 135         // Volatile
 136         {
 137             hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, '\u4567');
 138             char x = (char) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
 139             assertEquals(x, '\u4567', "setVolatile char value");
 140         }
 141 
 142         // Lazy
 143         {
 144             hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, '\u0123');
 145             char x = (char) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
 146             assertEquals(x, '\u0123', "setRelease char value");
 147         }
 148 
 149         // Opaque
 150         {
 151             hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, '\u4567');
 152             char x = (char) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
 153             assertEquals(x, '\u4567', "setOpaque char value");
 154         }
 155 
 156         hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 157 
 158         // Compare
 159         {
 160             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, '\u0123', '\u4567');
 161             assertEquals(r, true, "success compareAndSet char");
 162             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 163             assertEquals(x, '\u4567', "success compareAndSet char value");
 164         }
 165 
 166         {
 167             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, '\u0123', '\u89AB');
 168             assertEquals(r, false, "failing compareAndSet char");
 169             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 170             assertEquals(x, '\u4567', "failing compareAndSet char value");
 171         }
 172 
 173         {
 174             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(recv, '\u4567', '\u0123');
 175             assertEquals(r, '\u4567', "success compareAndExchange char");
 176             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 177             assertEquals(x, '\u0123', "success compareAndExchange char value");
 178         }
 179 
 180         {
 181             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(recv, '\u4567', '\u89AB');
 182             assertEquals(r, '\u0123', "failing compareAndExchange char");
 183             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 184             assertEquals(x, '\u0123', "failing compareAndExchange char value");
 185         }
 186 
 187         {
 188             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, '\u0123', '\u4567');
 189             assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
 190             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 191             assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
 192         }
 193 
 194         {
 195             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, '\u0123', '\u89AB');
 196             assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
 197             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 198             assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
 199         }
 200 
 201         {
 202             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, '\u4567', '\u0123');
 203             assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
 204             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 205             assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
 206         }
 207 
 208         {
 209             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, '\u4567', '\u89AB');
 210             assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
 211             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 212             assertEquals(x, '\u0123', "failing compareAndExchangeRelease char 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, '\u0123', '\u4567');
 220                 if (!success) weakDelay();
 221             }
 222             assertEquals(success, true, "success weakCompareAndSetPlain char");
 223             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 224             assertEquals(x, '\u4567', "success weakCompareAndSetPlain char value");
 225         }
 226 
 227         {
 228             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, '\u0123', '\u89AB');
 229             assertEquals(success, false, "failing weakCompareAndSetPlain char");
 230             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 231             assertEquals(x, '\u4567', "failing weakCompareAndSetPlain char 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, '\u4567', '\u0123');
 239                 if (!success) weakDelay();
 240             }
 241             assertEquals(success, true, "success weakCompareAndSetAcquire char");
 242             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 243             assertEquals(x, '\u0123', "success weakCompareAndSetAcquire char");
 244         }
 245 
 246         {
 247             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, '\u4567', '\u89AB');
 248             assertEquals(success, false, "failing weakCompareAndSetAcquire char");
 249             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 250             assertEquals(x, '\u0123', "failing weakCompareAndSetAcquire char 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, '\u0123', '\u4567');
 258                 if (!success) weakDelay();
 259             }
 260             assertEquals(success, true, "success weakCompareAndSetRelease char");
 261             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 262             assertEquals(x, '\u4567', "success weakCompareAndSetRelease char");
 263         }
 264 
 265         {
 266             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, '\u0123', '\u89AB');
 267             assertEquals(success, false, "failing weakCompareAndSetRelease char");
 268             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 269             assertEquals(x, '\u4567', "failing weakCompareAndSetRelease char 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, '\u4567', '\u0123');
 277                 if (!success) weakDelay();
 278             }
 279             assertEquals(success, true, "success weakCompareAndSet char");
 280             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 281             assertEquals(x, '\u0123', "success weakCompareAndSet char");
 282         }
 283 
 284         {
 285             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, '\u4567', '\u89AB');
 286             assertEquals(success, false, "failing weakCompareAndSet char");
 287             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 288             assertEquals(x, '\u0123', "failing weakCompareAndSet char value");
 289         }
 290 
 291         // Compare set and get
 292         {
 293             char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, '\u4567');
 294             assertEquals(o, '\u0123', "getAndSet char");
 295             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 296             assertEquals(x, '\u4567', "getAndSet char value");
 297         }
 298 
 299         // get and add, add and get
 300         {
 301             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 302 
 303             char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, '\u4567');
 304             assertEquals(o, '\u0123', "getAndAdd char");
 305             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 306             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value");
 307         }
 308 
 309         {
 310             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 311 
 312             char o = (char) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, '\u4567');
 313             assertEquals(o, '\u0123', "getAndAddAcquire char");
 314             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 315             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value");
 316         }
 317 
 318         {
 319             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 320 
 321             char o = (char) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, '\u4567');
 322             assertEquals(o, '\u0123', "getAndAddRelease char");
 323             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 324             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value");
 325         }
 326 
 327         // get and bitwise or
 328         {
 329             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 330 
 331             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, '\u4567');
 332             assertEquals(o, '\u0123', "getAndBitwiseOr char");
 333             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 334             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value");
 335         }
 336 
 337         {
 338             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 339 
 340             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, '\u4567');
 341             assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char");
 342             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 343             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value");
 344         }
 345 
 346         {
 347             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 348 
 349             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, '\u4567');
 350             assertEquals(o, '\u0123', "getAndBitwiseOrRelease char");
 351             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 352             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value");
 353         }
 354 
 355         // get and bitwise and
 356         {
 357             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 358 
 359             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, '\u4567');
 360             assertEquals(o, '\u0123', "getAndBitwiseAnd char");
 361             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 362             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value");
 363         }
 364 
 365         {
 366             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 367 
 368             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, '\u4567');
 369             assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char");
 370             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 371             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value");
 372         }
 373 
 374         {
 375             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 376 
 377             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, '\u4567');
 378             assertEquals(o, '\u0123', "getAndBitwiseAndRelease char");
 379             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 380             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value");
 381         }
 382 
 383         // get and bitwise xor
 384         {
 385             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 386 
 387             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, '\u4567');
 388             assertEquals(o, '\u0123', "getAndBitwiseXor char");
 389             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 390             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value");
 391         }
 392 
 393         {
 394             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 395 
 396             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, '\u4567');
 397             assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char");
 398             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 399             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value");
 400         }
 401 
 402         {
 403             hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
 404 
 405             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, '\u4567');
 406             assertEquals(o, '\u0123', "getAndBitwiseXorRelease char");
 407             char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
 408             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value");
 409         }
 410     }
 411 
 412     static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessChar recv, Handles hs) throws Throwable {
 413 
 414 
 415     }
 416 
 417 
 418     static void testStaticField(Handles hs) throws Throwable {
 419         // Plain
 420         {
 421             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 422             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 423             assertEquals(x, '\u0123', "set char value");
 424         }
 425 
 426 
 427         // Volatile
 428         {
 429             hs.get(TestAccessMode.SET_VOLATILE).invokeExact('\u4567');
 430             char x = (char) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
 431             assertEquals(x, '\u4567', "setVolatile char value");
 432         }
 433 
 434         // Lazy
 435         {
 436             hs.get(TestAccessMode.SET_RELEASE).invokeExact('\u0123');
 437             char x = (char) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
 438             assertEquals(x, '\u0123', "setRelease char value");
 439         }
 440 
 441         // Opaque
 442         {
 443             hs.get(TestAccessMode.SET_OPAQUE).invokeExact('\u4567');
 444             char x = (char) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
 445             assertEquals(x, '\u4567', "setOpaque char value");
 446         }
 447 
 448         hs.get(TestAccessMode.SET).invokeExact('\u0123');
 449 
 450         // Compare
 451         {
 452             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact('\u0123', '\u4567');
 453             assertEquals(r, true, "success compareAndSet char");
 454             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 455             assertEquals(x, '\u4567', "success compareAndSet char value");
 456         }
 457 
 458         {
 459             boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact('\u0123', '\u89AB');
 460             assertEquals(r, false, "failing compareAndSet char");
 461             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 462             assertEquals(x, '\u4567', "failing compareAndSet char value");
 463         }
 464 
 465         {
 466             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact('\u4567', '\u0123');
 467             assertEquals(r, '\u4567', "success compareAndExchange char");
 468             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 469             assertEquals(x, '\u0123', "success compareAndExchange char value");
 470         }
 471 
 472         {
 473             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact('\u4567', '\u89AB');
 474             assertEquals(r, '\u0123', "failing compareAndExchange char");
 475             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 476             assertEquals(x, '\u0123', "failing compareAndExchange char value");
 477         }
 478 
 479         {
 480             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact('\u0123', '\u4567');
 481             assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
 482             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 483             assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
 484         }
 485 
 486         {
 487             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact('\u0123', '\u89AB');
 488             assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
 489             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 490             assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
 491         }
 492 
 493         {
 494             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact('\u4567', '\u0123');
 495             assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
 496             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 497             assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
 498         }
 499 
 500         {
 501             char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact('\u4567', '\u89AB');
 502             assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
 503             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 504             assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
 505         }
 506 
 507         {
 508             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN);
 509             boolean success = false;
 510             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 511                 success = (boolean) mh.invokeExact('\u0123', '\u4567');
 512                 if (!success) weakDelay();
 513             }
 514             assertEquals(success, true, "success weakCompareAndSetPlain char");
 515             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 516             assertEquals(x, '\u4567', "success weakCompareAndSetPlain char value");
 517         }
 518 
 519         {
 520             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact('\u0123', '\u89AB');
 521             assertEquals(success, false, "failing weakCompareAndSetPlain char");
 522             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 523             assertEquals(x, '\u4567', "failing weakCompareAndSetPlain char value");
 524         }
 525 
 526         {
 527             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE);
 528             boolean success = false;
 529             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 530                 success = (boolean) mh.invokeExact('\u4567', '\u0123');
 531                 if (!success) weakDelay();
 532             }
 533             assertEquals(success, true, "success weakCompareAndSetAcquire char");
 534             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 535             assertEquals(x, '\u0123', "success weakCompareAndSetAcquire char");
 536         }
 537 
 538         {
 539             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE);
 540             boolean success = (boolean) mh.invokeExact('\u4567', '\u89AB');
 541             assertEquals(success, false, "failing weakCompareAndSetAcquire char");
 542             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 543             assertEquals(x, '\u0123', "failing weakCompareAndSetAcquire char value");
 544         }
 545 
 546         {
 547             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE);
 548             boolean success = false;
 549             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 550                 success = (boolean) mh.invokeExact('\u0123', '\u4567');
 551                 if (!success) weakDelay();
 552             }
 553             assertEquals(success, true, "success weakCompareAndSetRelease char");
 554             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 555             assertEquals(x, '\u4567', "success weakCompareAndSetRelease char");
 556         }
 557 
 558         {
 559             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact('\u0123', '\u89AB');
 560             assertEquals(success, false, "failing weakCompareAndSetRelease char");
 561             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 562             assertEquals(x, '\u4567', "failing weakCompareAndSetRelease char value");
 563         }
 564 
 565         {
 566             MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET);
 567             boolean success = false;
 568             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 569                 success = (boolean) mh.invokeExact('\u4567', '\u0123');
 570                 if (!success) weakDelay();
 571             }
 572             assertEquals(success, true, "success weakCompareAndSet char");
 573             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 574             assertEquals(x, '\u0123', "success weakCompareAndSet char");
 575         }
 576 
 577         {
 578             boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact('\u4567', '\u89AB');
 579             assertEquals(success, false, "failing weakCompareAndSet char");
 580             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 581             assertEquals(x, '\u0123', "failing weakCompareAndSetRe char value");
 582         }
 583 
 584         // Compare set and get
 585         {
 586             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 587 
 588             char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact('\u4567');
 589             assertEquals(o, '\u0123', "getAndSet char");
 590             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 591             assertEquals(x, '\u4567', "getAndSet char value");
 592         }
 593 
 594         // Compare set and get
 595         {
 596             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 597 
 598             char o = (char) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact('\u4567');
 599             assertEquals(o, '\u0123', "getAndSetAcquire char");
 600             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 601             assertEquals(x, '\u4567', "getAndSetAcquire char value");
 602         }
 603 
 604         // Compare set and get
 605         {
 606             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 607 
 608             char o = (char) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact('\u4567');
 609             assertEquals(o, '\u0123', "getAndSetRelease char");
 610             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 611             assertEquals(x, '\u4567', "getAndSetRelease char value");
 612         }
 613 
 614         // get and add, add and get
 615         {
 616             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 617 
 618             char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact('\u4567');
 619             assertEquals(o, '\u0123', "getAndAdd char");
 620             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 621             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value");
 622         }
 623 
 624         {
 625             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 626 
 627             char o = (char) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact('\u4567');
 628             assertEquals(o, '\u0123', "getAndAddAcquire char");
 629             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 630             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value");
 631         }
 632 
 633         {
 634             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 635 
 636             char o = (char) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact('\u4567');
 637             assertEquals(o, '\u0123', "getAndAddRelease char");
 638             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 639             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value");
 640         }
 641 
 642         // get and bitwise or
 643         {
 644             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 645 
 646             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact('\u4567');
 647             assertEquals(o, '\u0123', "getAndBitwiseOr char");
 648             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 649             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value");
 650         }
 651 
 652         {
 653             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 654 
 655             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact('\u4567');
 656             assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char");
 657             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 658             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value");
 659         }
 660 
 661         {
 662             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 663 
 664             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact('\u4567');
 665             assertEquals(o, '\u0123', "getAndBitwiseOrRelease char");
 666             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 667             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value");
 668         }
 669 
 670         // get and bitwise and
 671         {
 672             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 673 
 674             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact('\u4567');
 675             assertEquals(o, '\u0123', "getAndBitwiseAnd char");
 676             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 677             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value");
 678         }
 679 
 680         {
 681             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 682 
 683             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact('\u4567');
 684             assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char");
 685             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 686             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value");
 687         }
 688 
 689         {
 690             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 691 
 692             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact('\u4567');
 693             assertEquals(o, '\u0123', "getAndBitwiseAndRelease char");
 694             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 695             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value");
 696         }
 697 
 698         // get and bitwise xor
 699         {
 700             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 701 
 702             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact('\u4567');
 703             assertEquals(o, '\u0123', "getAndBitwiseXor char");
 704             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 705             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value");
 706         }
 707 
 708         {
 709             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 710 
 711             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact('\u4567');
 712             assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char");
 713             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 714             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value");
 715         }
 716 
 717         {
 718             hs.get(TestAccessMode.SET).invokeExact('\u0123');
 719 
 720             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact('\u4567');
 721             assertEquals(o, '\u0123', "getAndBitwiseXorRelease char");
 722             char x = (char) hs.get(TestAccessMode.GET).invokeExact();
 723             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value");
 724         }
 725     }
 726 
 727     static void testStaticFieldUnsupported(Handles hs) throws Throwable {
 728 
 729 
 730     }
 731 
 732 
 733     static void testArray(Handles hs) throws Throwable {
 734         char[] array = new char[10];
 735 
 736         for (int i = 0; i < array.length; i++) {
 737             // Plain
 738             {
 739                 hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 740                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 741                 assertEquals(x, '\u0123', "get char value");
 742             }
 743 
 744 
 745             // Volatile
 746             {
 747                 hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, '\u4567');
 748                 char x = (char) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
 749                 assertEquals(x, '\u4567', "setVolatile char value");
 750             }
 751 
 752             // Lazy
 753             {
 754                 hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, '\u0123');
 755                 char x = (char) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
 756                 assertEquals(x, '\u0123', "setRelease char value");
 757             }
 758 
 759             // Opaque
 760             {
 761                 hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, '\u4567');
 762                 char x = (char) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
 763                 assertEquals(x, '\u4567', "setOpaque char value");
 764             }
 765 
 766             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 767 
 768             // Compare
 769             {
 770                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, '\u0123', '\u4567');
 771                 assertEquals(r, true, "success compareAndSet char");
 772                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 773                 assertEquals(x, '\u4567', "success compareAndSet char value");
 774             }
 775 
 776             {
 777                 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, '\u0123', '\u89AB');
 778                 assertEquals(r, false, "failing compareAndSet char");
 779                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 780                 assertEquals(x, '\u4567', "failing compareAndSet char value");
 781             }
 782 
 783             {
 784                 char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(array, i, '\u4567', '\u0123');
 785                 assertEquals(r, '\u4567', "success compareAndExchange char");
 786                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 787                 assertEquals(x, '\u0123', "success compareAndExchange char value");
 788             }
 789 
 790             {
 791                 char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(array, i, '\u4567', '\u89AB');
 792                 assertEquals(r, '\u0123', "failing compareAndExchange char");
 793                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 794                 assertEquals(x, '\u0123', "failing compareAndExchange char value");
 795             }
 796 
 797             {
 798                 char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, '\u0123', '\u4567');
 799                 assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
 800                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 801                 assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
 802             }
 803 
 804             {
 805                 char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, '\u0123', '\u89AB');
 806                 assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
 807                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 808                 assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
 809             }
 810 
 811             {
 812                 char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, '\u4567', '\u0123');
 813                 assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
 814                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 815                 assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
 816             }
 817 
 818             {
 819                 char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, '\u4567', '\u89AB');
 820                 assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
 821                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 822                 assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
 823             }
 824 
 825             {
 826                 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN);
 827                 boolean success = false;
 828                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 829                     success = (boolean) mh.invokeExact(array, i, '\u0123', '\u4567');
 830                     if (!success) weakDelay();
 831                 }
 832                 assertEquals(success, true, "success weakCompareAndSetPlain char");
 833                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 834                 assertEquals(x, '\u4567', "success weakCompareAndSetPlain char value");
 835             }
 836 
 837             {
 838                 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, '\u0123', '\u89AB');
 839                 assertEquals(success, false, "failing weakCompareAndSetPlain char");
 840                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 841                 assertEquals(x, '\u4567', "failing weakCompareAndSetPlain char value");
 842             }
 843 
 844             {
 845                 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE);
 846                 boolean success = false;
 847                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 848                     success = (boolean) mh.invokeExact(array, i, '\u4567', '\u0123');
 849                     if (!success) weakDelay();
 850                 }
 851                 assertEquals(success, true, "success weakCompareAndSetAcquire char");
 852                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 853                 assertEquals(x, '\u0123', "success weakCompareAndSetAcquire char");
 854             }
 855 
 856             {
 857                 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, '\u4567', '\u89AB');
 858                 assertEquals(success, false, "failing weakCompareAndSetAcquire char");
 859                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 860                 assertEquals(x, '\u0123', "failing weakCompareAndSetAcquire char value");
 861             }
 862 
 863             {
 864                 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE);
 865                 boolean success = false;
 866                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 867                     success = (boolean) mh.invokeExact(array, i, '\u0123', '\u4567');
 868                     if (!success) weakDelay();
 869                 }
 870                 assertEquals(success, true, "success weakCompareAndSetRelease char");
 871                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 872                 assertEquals(x, '\u4567', "success weakCompareAndSetRelease char");
 873             }
 874 
 875             {
 876                 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, '\u0123', '\u89AB');
 877                 assertEquals(success, false, "failing weakCompareAndSetAcquire char");
 878                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 879                 assertEquals(x, '\u4567', "failing weakCompareAndSetAcquire char value");
 880             }
 881 
 882             {
 883                 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET);
 884                 boolean success = false;
 885                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 886                     success = (boolean) mh.invokeExact(array, i, '\u4567', '\u0123');
 887                     if (!success) weakDelay();
 888                 }
 889                 assertEquals(success, true, "success weakCompareAndSet char");
 890                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 891                 assertEquals(x, '\u0123', "success weakCompareAndSet char");
 892             }
 893 
 894             {
 895                 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, '\u4567', '\u89AB');
 896                 assertEquals(success, false, "failing weakCompareAndSet char");
 897                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 898                 assertEquals(x, '\u0123', "failing weakCompareAndSet char value");
 899             }
 900 
 901             // Compare set and get
 902             {
 903                 hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 904 
 905                 char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, '\u4567');
 906                 assertEquals(o, '\u0123', "getAndSet char");
 907                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 908                 assertEquals(x, '\u4567', "getAndSet char value");
 909             }
 910 
 911             {
 912                 hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 913 
 914                 char o = (char) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, '\u4567');
 915                 assertEquals(o, '\u0123', "getAndSetAcquire char");
 916                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 917                 assertEquals(x, '\u4567', "getAndSetAcquire char value");
 918             }
 919 
 920             {
 921                 hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 922 
 923                 char o = (char) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, '\u4567');
 924                 assertEquals(o, '\u0123', "getAndSetRelease char");
 925                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 926                 assertEquals(x, '\u4567', "getAndSetRelease char value");
 927             }
 928 
 929             // get and add, add and get
 930             {
 931                 hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 932 
 933                 char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, '\u4567');
 934                 assertEquals(o, '\u0123', "getAndAdd char");
 935                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 936                 assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value");
 937             }
 938 
 939             {
 940                 hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 941 
 942                 char o = (char) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, '\u4567');
 943                 assertEquals(o, '\u0123', "getAndAddAcquire char");
 944                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 945                 assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value");
 946             }
 947 
 948             {
 949                 hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 950 
 951                 char o = (char) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, '\u4567');
 952                 assertEquals(o, '\u0123', "getAndAddRelease char");
 953                 char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 954                 assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value");
 955             }
 956 
 957         // get and bitwise or
 958         {
 959             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 960 
 961             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, '\u4567');
 962             assertEquals(o, '\u0123', "getAndBitwiseOr char");
 963             char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 964             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value");
 965         }
 966 
 967         {
 968             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 969 
 970             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, '\u4567');
 971             assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char");
 972             char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 973             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value");
 974         }
 975 
 976         {
 977             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 978 
 979             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, '\u4567');
 980             assertEquals(o, '\u0123', "getAndBitwiseOrRelease char");
 981             char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 982             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value");
 983         }
 984 
 985         // get and bitwise and
 986         {
 987             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 988 
 989             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, '\u4567');
 990             assertEquals(o, '\u0123', "getAndBitwiseAnd char");
 991             char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
 992             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value");
 993         }
 994 
 995         {
 996             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
 997 
 998             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, '\u4567');
 999             assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char");
1000             char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
1001             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value");
1002         }
1003 
1004         {
1005             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
1006 
1007             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, '\u4567');
1008             assertEquals(o, '\u0123', "getAndBitwiseAndRelease char");
1009             char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
1010             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value");
1011         }
1012 
1013         // get and bitwise xor
1014         {
1015             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
1016 
1017             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, '\u4567');
1018             assertEquals(o, '\u0123', "getAndBitwiseXor char");
1019             char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
1020             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value");
1021         }
1022 
1023         {
1024             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
1025 
1026             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, '\u4567');
1027             assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char");
1028             char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
1029             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value");
1030         }
1031 
1032         {
1033             hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
1034 
1035             char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, '\u4567');
1036             assertEquals(o, '\u0123', "getAndBitwiseXorRelease char");
1037             char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
1038             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value");
1039         }
1040         }
1041     }
1042 
1043     static void testArrayUnsupported(Handles hs) throws Throwable {
1044         char[] array = new char[10];
1045 
1046         final int i = 0;
1047 
1048 
1049     }
1050 
1051     static void testArrayIndexOutOfBounds(Handles hs) throws Throwable {
1052         char[] array = new char[10];
1053 
1054         for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
1055             final int ci = i;
1056 
1057             for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
1058                 checkAIOOBE(am, () -> {
1059                     char x = (char) hs.get(am).invokeExact(array, ci);
1060                 });
1061             }
1062 
1063             for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
1064                 checkAIOOBE(am, () -> {
1065                     hs.get(am).invokeExact(array, ci, '\u0123');
1066                 });
1067             }
1068 
1069             for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
1070                 checkAIOOBE(am, () -> {
1071                     boolean r = (boolean) hs.get(am).invokeExact(array, ci, '\u0123', '\u4567');
1072                 });
1073             }
1074 
1075             for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
1076                 checkAIOOBE(am, () -> {
1077                     char r = (char) hs.get(am).invokeExact(array, ci, '\u4567', '\u0123');
1078                 });
1079             }
1080 
1081             for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
1082                 checkAIOOBE(am, () -> {
1083                     char o = (char) hs.get(am).invokeExact(array, ci, '\u0123');
1084                 });
1085             }
1086 
1087             for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
1088                 checkAIOOBE(am, () -> {
1089                     char o = (char) hs.get(am).invokeExact(array, ci, '\u89AB');
1090                 });
1091             }
1092 
1093             for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) {
1094                 checkAIOOBE(am, () -> {
1095                     char o = (char) hs.get(am).invokeExact(array, ci, '\u89AB');
1096                 });
1097             }
1098         }
1099     }
1100 }
1101