1 /*
   2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @run testng/othervm -Diters=10    -Xint                   VarHandleTestAccessChar
  27  * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessChar
  28  * @run testng/othervm -Diters=20000                         VarHandleTestAccessChar
  29  * @run testng/othervm -Diters=20000 -XX:-TieredCompilation  VarHandleTestAccessChar
  30  */
  31 
  32 import org.testng.annotations.BeforeClass;
  33 import org.testng.annotations.DataProvider;
  34 import org.testng.annotations.Test;
  35 
  36 import java.lang.invoke.MethodHandles;
  37 import java.lang.invoke.VarHandle;
  38 import java.util.ArrayList;
  39 import java.util.Arrays;
  40 import java.util.List;
  41 
  42 import static org.testng.Assert.*;
  43 
  44 public class VarHandleTestAccessChar extends VarHandleBaseTest {
  45     static final char static_final_v = '\u0123';
  46 
  47     static char static_v;
  48 
  49     final char final_v = '\u0123';
  50 
  51     char v;
  52 
  53     VarHandle vhFinalField;
  54 
  55     VarHandle vhField;
  56 
  57     VarHandle vhStaticField;
  58 
  59     VarHandle vhStaticFinalField;
  60 
  61     VarHandle vhArray;
  62 
  63 
  64     @BeforeClass
  65     public void setup() throws Exception {
  66         vhFinalField = MethodHandles.lookup().findVarHandle(
  67                 VarHandleTestAccessChar.class, "final_v", char.class);
  68 
  69         vhField = MethodHandles.lookup().findVarHandle(
  70                 VarHandleTestAccessChar.class, "v", char.class);
  71 
  72         vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
  73             VarHandleTestAccessChar.class, "static_final_v", char.class);
  74 
  75         vhStaticField = MethodHandles.lookup().findStaticVarHandle(
  76             VarHandleTestAccessChar.class, "static_v", char.class);
  77 
  78         vhArray = MethodHandles.arrayElementVarHandle(char[].class);
  79     }
  80 
  81 
  82     @DataProvider
  83     public Object[][] varHandlesProvider() throws Exception {
  84         List<VarHandle> vhs = new ArrayList<>();
  85         vhs.add(vhField);
  86         vhs.add(vhStaticField);
  87         vhs.add(vhArray);
  88 
  89         return vhs.stream().map(tc -> new Object[]{tc}).toArray(Object[][]::new);
  90     }
  91 
  92     @Test(dataProvider = "varHandlesProvider")
  93     public void testIsAccessModeSupported(VarHandle vh) {
  94         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET));
  95         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET));
  96         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_VOLATILE));
  97         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_VOLATILE));
  98         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_ACQUIRE));
  99         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_RELEASE));
 100         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
 101         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
 102 
 103         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
 104         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE));
 105         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
 106         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
 107         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN));
 108         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
 109         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
 110         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
 111         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
 112         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE));
 113         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE));
 114 
 115         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
 116         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE));
 117         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE));
 118 
 119         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR));
 120         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE));
 121         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE));
 122         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND));
 123         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE));
 124         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE));
 125         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR));
 126         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE));
 127         assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE));
 128     }
 129 
 130 
 131     @DataProvider
 132     public Object[][] typesProvider() throws Exception {
 133         List<Object[]> types = new ArrayList<>();
 134         types.add(new Object[] {vhField, Arrays.asList(VarHandleTestAccessChar.class)});
 135         types.add(new Object[] {vhStaticField, Arrays.asList()});
 136         types.add(new Object[] {vhArray, Arrays.asList(char[].class, int.class)});
 137 
 138         return types.stream().toArray(Object[][]::new);
 139     }
 140 
 141     @Test(dataProvider = "typesProvider")
 142     public void testTypes(VarHandle vh, List<Class<?>> pts) {
 143         assertEquals(vh.varType(), char.class);
 144 
 145         assertEquals(vh.coordinateTypes(), pts);
 146 
 147         testTypes(vh);
 148     }
 149 
 150 
 151     @Test
 152     public void testLookupInstanceToStatic() {
 153         checkIAE("Lookup of static final field to instance final field", () -> {
 154             MethodHandles.lookup().findStaticVarHandle(
 155                     VarHandleTestAccessChar.class, "final_v", char.class);
 156         });
 157 
 158         checkIAE("Lookup of static field to instance field", () -> {
 159             MethodHandles.lookup().findStaticVarHandle(
 160                     VarHandleTestAccessChar.class, "v", char.class);
 161         });
 162     }
 163 
 164     @Test
 165     public void testLookupStaticToInstance() {
 166         checkIAE("Lookup of instance final field to static final field", () -> {
 167             MethodHandles.lookup().findVarHandle(
 168                 VarHandleTestAccessChar.class, "static_final_v", char.class);
 169         });
 170 
 171         checkIAE("Lookup of instance field to static field", () -> {
 172             vhStaticField = MethodHandles.lookup().findVarHandle(
 173                 VarHandleTestAccessChar.class, "static_v", char.class);
 174         });
 175     }
 176 
 177 
 178     @DataProvider
 179     public Object[][] accessTestCaseProvider() throws Exception {
 180         List<AccessTestCase<?>> cases = new ArrayList<>();
 181 
 182         cases.add(new VarHandleAccessTestCase("Instance final field",
 183                                               vhFinalField, vh -> testInstanceFinalField(this, vh)));
 184         cases.add(new VarHandleAccessTestCase("Instance final field unsupported",
 185                                               vhFinalField, vh -> testInstanceFinalFieldUnsupported(this, vh),
 186                                               false));
 187 
 188         cases.add(new VarHandleAccessTestCase("Static final field",
 189                                               vhStaticFinalField, VarHandleTestAccessChar::testStaticFinalField));
 190         cases.add(new VarHandleAccessTestCase("Static final field unsupported",
 191                                               vhStaticFinalField, VarHandleTestAccessChar::testStaticFinalFieldUnsupported,
 192                                               false));
 193 
 194         cases.add(new VarHandleAccessTestCase("Instance field",
 195                                               vhField, vh -> testInstanceField(this, vh)));
 196         cases.add(new VarHandleAccessTestCase("Instance field unsupported",
 197                                               vhField, vh -> testInstanceFieldUnsupported(this, vh),
 198                                               false));
 199 
 200         cases.add(new VarHandleAccessTestCase("Static field",
 201                                               vhStaticField, VarHandleTestAccessChar::testStaticField));
 202         cases.add(new VarHandleAccessTestCase("Static field unsupported",
 203                                               vhStaticField, VarHandleTestAccessChar::testStaticFieldUnsupported,
 204                                               false));
 205 
 206         cases.add(new VarHandleAccessTestCase("Array",
 207                                               vhArray, VarHandleTestAccessChar::testArray));
 208         cases.add(new VarHandleAccessTestCase("Array unsupported",
 209                                               vhArray, VarHandleTestAccessChar::testArrayUnsupported,
 210                                               false));
 211         cases.add(new VarHandleAccessTestCase("Array index out of bounds",
 212                                               vhArray, VarHandleTestAccessChar::testArrayIndexOutOfBounds,
 213                                               false));
 214         // Work around issue with jtreg summary reporting which truncates
 215         // the String result of Object.toString to 30 characters, hence
 216         // the first dummy argument
 217         return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new);
 218     }
 219 
 220     @Test(dataProvider = "accessTestCaseProvider")
 221     public <T> void testAccess(String desc, AccessTestCase<T> atc) throws Throwable {
 222         T t = atc.get();
 223         int iters = atc.requiresLoop() ? ITERS : 1;
 224         for (int c = 0; c < iters; c++) {
 225             atc.testAccess(t);
 226         }
 227     }
 228 
 229 
 230 
 231 
 232     static void testInstanceFinalField(VarHandleTestAccessChar recv, VarHandle vh) {
 233         // Plain
 234         {
 235             char x = (char) vh.get(recv);
 236             assertEquals(x, '\u0123', "get char value");
 237         }
 238 
 239 
 240         // Volatile
 241         {
 242             char x = (char) vh.getVolatile(recv);
 243             assertEquals(x, '\u0123', "getVolatile char value");
 244         }
 245 
 246         // Lazy
 247         {
 248             char x = (char) vh.getAcquire(recv);
 249             assertEquals(x, '\u0123', "getRelease char value");
 250         }
 251 
 252         // Opaque
 253         {
 254             char x = (char) vh.getOpaque(recv);
 255             assertEquals(x, '\u0123', "getOpaque char value");
 256         }
 257     }
 258 
 259     static void testInstanceFinalFieldUnsupported(VarHandleTestAccessChar recv, VarHandle vh) {
 260         checkUOE(() -> {
 261             vh.set(recv, '\u4567');
 262         });
 263 
 264         checkUOE(() -> {
 265             vh.setVolatile(recv, '\u4567');
 266         });
 267 
 268         checkUOE(() -> {
 269             vh.setRelease(recv, '\u4567');
 270         });
 271 
 272         checkUOE(() -> {
 273             vh.setOpaque(recv, '\u4567');
 274         });
 275 
 276 
 277 
 278     }
 279 
 280 
 281     static void testStaticFinalField(VarHandle vh) {
 282         // Plain
 283         {
 284             char x = (char) vh.get();
 285             assertEquals(x, '\u0123', "get char value");
 286         }
 287 
 288 
 289         // Volatile
 290         {
 291             char x = (char) vh.getVolatile();
 292             assertEquals(x, '\u0123', "getVolatile char value");
 293         }
 294 
 295         // Lazy
 296         {
 297             char x = (char) vh.getAcquire();
 298             assertEquals(x, '\u0123', "getRelease char value");
 299         }
 300 
 301         // Opaque
 302         {
 303             char x = (char) vh.getOpaque();
 304             assertEquals(x, '\u0123', "getOpaque char value");
 305         }
 306     }
 307 
 308     static void testStaticFinalFieldUnsupported(VarHandle vh) {
 309         checkUOE(() -> {
 310             vh.set('\u4567');
 311         });
 312 
 313         checkUOE(() -> {
 314             vh.setVolatile('\u4567');
 315         });
 316 
 317         checkUOE(() -> {
 318             vh.setRelease('\u4567');
 319         });
 320 
 321         checkUOE(() -> {
 322             vh.setOpaque('\u4567');
 323         });
 324 
 325 
 326 
 327     }
 328 
 329 
 330     static void testInstanceField(VarHandleTestAccessChar recv, VarHandle vh) {
 331         // Plain
 332         {
 333             vh.set(recv, '\u0123');
 334             char x = (char) vh.get(recv);
 335             assertEquals(x, '\u0123', "set char value");
 336         }
 337 
 338 
 339         // Volatile
 340         {
 341             vh.setVolatile(recv, '\u4567');
 342             char x = (char) vh.getVolatile(recv);
 343             assertEquals(x, '\u4567', "setVolatile char value");
 344         }
 345 
 346         // Lazy
 347         {
 348             vh.setRelease(recv, '\u0123');
 349             char x = (char) vh.getAcquire(recv);
 350             assertEquals(x, '\u0123', "setRelease char value");
 351         }
 352 
 353         // Opaque
 354         {
 355             vh.setOpaque(recv, '\u4567');
 356             char x = (char) vh.getOpaque(recv);
 357             assertEquals(x, '\u4567', "setOpaque char value");
 358         }
 359 
 360         vh.set(recv, '\u0123');
 361 
 362         // Compare
 363         {
 364             boolean r = vh.compareAndSet(recv, '\u0123', '\u4567');
 365             assertEquals(r, true, "success compareAndSet char");
 366             char x = (char) vh.get(recv);
 367             assertEquals(x, '\u4567', "success compareAndSet char value");
 368         }
 369 
 370         {
 371             boolean r = vh.compareAndSet(recv, '\u0123', '\u89AB');
 372             assertEquals(r, false, "failing compareAndSet char");
 373             char x = (char) vh.get(recv);
 374             assertEquals(x, '\u4567', "failing compareAndSet char value");
 375         }
 376 
 377         {
 378             char r = (char) vh.compareAndExchange(recv, '\u4567', '\u0123');
 379             assertEquals(r, '\u4567', "success compareAndExchange char");
 380             char x = (char) vh.get(recv);
 381             assertEquals(x, '\u0123', "success compareAndExchange char value");
 382         }
 383 
 384         {
 385             char r = (char) vh.compareAndExchange(recv, '\u4567', '\u89AB');
 386             assertEquals(r, '\u0123', "failing compareAndExchange char");
 387             char x = (char) vh.get(recv);
 388             assertEquals(x, '\u0123', "failing compareAndExchange char value");
 389         }
 390 
 391         {
 392             char r = (char) vh.compareAndExchangeAcquire(recv, '\u0123', '\u4567');
 393             assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
 394             char x = (char) vh.get(recv);
 395             assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
 396         }
 397 
 398         {
 399             char r = (char) vh.compareAndExchangeAcquire(recv, '\u0123', '\u89AB');
 400             assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
 401             char x = (char) vh.get(recv);
 402             assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
 403         }
 404 
 405         {
 406             char r = (char) vh.compareAndExchangeRelease(recv, '\u4567', '\u0123');
 407             assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
 408             char x = (char) vh.get(recv);
 409             assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
 410         }
 411 
 412         {
 413             char r = (char) vh.compareAndExchangeRelease(recv, '\u4567', '\u89AB');
 414             assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
 415             char x = (char) vh.get(recv);
 416             assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
 417         }
 418 
 419         {
 420             boolean success = false;
 421             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 422                 success = vh.weakCompareAndSetPlain(recv, '\u0123', '\u4567');
 423             }
 424             assertEquals(success, true, "weakCompareAndSetPlain char");
 425             char x = (char) vh.get(recv);
 426             assertEquals(x, '\u4567', "weakCompareAndSetPlain char value");
 427         }
 428 
 429         {
 430             boolean success = false;
 431             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 432                 success = vh.weakCompareAndSetAcquire(recv, '\u4567', '\u0123');
 433             }
 434             assertEquals(success, true, "weakCompareAndSetAcquire char");
 435             char x = (char) vh.get(recv);
 436             assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
 437         }
 438 
 439         {
 440             boolean success = false;
 441             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 442                 success = vh.weakCompareAndSetRelease(recv, '\u0123', '\u4567');
 443             }
 444             assertEquals(success, true, "weakCompareAndSetRelease char");
 445             char x = (char) vh.get(recv);
 446             assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
 447         }
 448 
 449         {
 450             boolean success = false;
 451             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 452                 success = vh.weakCompareAndSet(recv, '\u4567', '\u0123');
 453             }
 454             assertEquals(success, true, "weakCompareAndSet char");
 455             char x = (char) vh.get(recv);
 456             assertEquals(x, '\u0123', "weakCompareAndSet char value");
 457         }
 458 
 459         // Compare set and get
 460         {
 461             vh.set(recv, '\u0123');
 462 
 463             char o = (char) vh.getAndSet(recv, '\u4567');
 464             assertEquals(o, '\u0123', "getAndSet char");
 465             char x = (char) vh.get(recv);
 466             assertEquals(x, '\u4567', "getAndSet char value");
 467         }
 468 
 469         {
 470             vh.set(recv, '\u0123');
 471 
 472             char o = (char) vh.getAndSetAcquire(recv, '\u4567');
 473             assertEquals(o, '\u0123', "getAndSetAcquire char");
 474             char x = (char) vh.get(recv);
 475             assertEquals(x, '\u4567', "getAndSetAcquire char value");
 476         }
 477 
 478         {
 479             vh.set(recv, '\u0123');
 480 
 481             char o = (char) vh.getAndSetRelease(recv, '\u4567');
 482             assertEquals(o, '\u0123', "getAndSetRelease char");
 483             char x = (char) vh.get(recv);
 484             assertEquals(x, '\u4567', "getAndSetRelease char value");
 485         }
 486 
 487         // get and add, add and get
 488         {
 489             vh.set(recv, '\u0123');
 490 
 491             char o = (char) vh.getAndAdd(recv, '\u4567');
 492             assertEquals(o, '\u0123', "getAndAdd char");
 493             char x = (char) vh.get(recv);
 494             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value");
 495         }
 496 
 497         {
 498             vh.set(recv, '\u0123');
 499 
 500             char o = (char) vh.getAndAddAcquire(recv, '\u4567');
 501             assertEquals(o, '\u0123', "getAndAddAcquire char");
 502             char x = (char) vh.get(recv);
 503             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value");
 504         }
 505 
 506         {
 507             vh.set(recv, '\u0123');
 508 
 509             char o = (char) vh.getAndAddRelease(recv, '\u4567');
 510             assertEquals(o, '\u0123', "getAndAddReleasechar");
 511             char x = (char) vh.get(recv);
 512             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value");
 513         }
 514 
 515         // get and bitwise or
 516         {
 517             vh.set(recv, '\u0123');
 518 
 519             char o = (char) vh.getAndBitwiseOr(recv, '\u4567');
 520             assertEquals(o, '\u0123', "getAndBitwiseOr char");
 521             char x = (char) vh.get(recv);
 522             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value");
 523         }
 524 
 525         {
 526             vh.set(recv, '\u0123');
 527 
 528             char o = (char) vh.getAndBitwiseOrAcquire(recv, '\u4567');
 529             assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char");
 530             char x = (char) vh.get(recv);
 531             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value");
 532         }
 533 
 534         {
 535             vh.set(recv, '\u0123');
 536 
 537             char o = (char) vh.getAndBitwiseOrRelease(recv, '\u4567');
 538             assertEquals(o, '\u0123', "getAndBitwiseOrRelease char");
 539             char x = (char) vh.get(recv);
 540             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value");
 541         }
 542 
 543         // get and bitwise and
 544         {
 545             vh.set(recv, '\u0123');
 546 
 547             char o = (char) vh.getAndBitwiseAnd(recv, '\u4567');
 548             assertEquals(o, '\u0123', "getAndBitwiseAnd char");
 549             char x = (char) vh.get(recv);
 550             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value");
 551         }
 552 
 553         {
 554             vh.set(recv, '\u0123');
 555 
 556             char o = (char) vh.getAndBitwiseAndAcquire(recv, '\u4567');
 557             assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char");
 558             char x = (char) vh.get(recv);
 559             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value");
 560         }
 561 
 562         {
 563             vh.set(recv, '\u0123');
 564 
 565             char o = (char) vh.getAndBitwiseAndRelease(recv, '\u4567');
 566             assertEquals(o, '\u0123', "getAndBitwiseAndRelease char");
 567             char x = (char) vh.get(recv);
 568             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value");
 569         }
 570 
 571         // get and bitwise xor
 572         {
 573             vh.set(recv, '\u0123');
 574 
 575             char o = (char) vh.getAndBitwiseXor(recv, '\u4567');
 576             assertEquals(o, '\u0123', "getAndBitwiseXor char");
 577             char x = (char) vh.get(recv);
 578             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value");
 579         }
 580 
 581         {
 582             vh.set(recv, '\u0123');
 583 
 584             char o = (char) vh.getAndBitwiseXorAcquire(recv, '\u4567');
 585             assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char");
 586             char x = (char) vh.get(recv);
 587             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value");
 588         }
 589 
 590         {
 591             vh.set(recv, '\u0123');
 592 
 593             char o = (char) vh.getAndBitwiseXorRelease(recv, '\u4567');
 594             assertEquals(o, '\u0123', "getAndBitwiseXorRelease char");
 595             char x = (char) vh.get(recv);
 596             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value");
 597         }
 598     }
 599 
 600     static void testInstanceFieldUnsupported(VarHandleTestAccessChar recv, VarHandle vh) {
 601 
 602 
 603     }
 604 
 605 
 606     static void testStaticField(VarHandle vh) {
 607         // Plain
 608         {
 609             vh.set('\u0123');
 610             char x = (char) vh.get();
 611             assertEquals(x, '\u0123', "set char value");
 612         }
 613 
 614 
 615         // Volatile
 616         {
 617             vh.setVolatile('\u4567');
 618             char x = (char) vh.getVolatile();
 619             assertEquals(x, '\u4567', "setVolatile char value");
 620         }
 621 
 622         // Lazy
 623         {
 624             vh.setRelease('\u0123');
 625             char x = (char) vh.getAcquire();
 626             assertEquals(x, '\u0123', "setRelease char value");
 627         }
 628 
 629         // Opaque
 630         {
 631             vh.setOpaque('\u4567');
 632             char x = (char) vh.getOpaque();
 633             assertEquals(x, '\u4567', "setOpaque char value");
 634         }
 635 
 636         vh.set('\u0123');
 637 
 638         // Compare
 639         {
 640             boolean r = vh.compareAndSet('\u0123', '\u4567');
 641             assertEquals(r, true, "success compareAndSet char");
 642             char x = (char) vh.get();
 643             assertEquals(x, '\u4567', "success compareAndSet char value");
 644         }
 645 
 646         {
 647             boolean r = vh.compareAndSet('\u0123', '\u89AB');
 648             assertEquals(r, false, "failing compareAndSet char");
 649             char x = (char) vh.get();
 650             assertEquals(x, '\u4567', "failing compareAndSet char value");
 651         }
 652 
 653         {
 654             char r = (char) vh.compareAndExchange('\u4567', '\u0123');
 655             assertEquals(r, '\u4567', "success compareAndExchange char");
 656             char x = (char) vh.get();
 657             assertEquals(x, '\u0123', "success compareAndExchange char value");
 658         }
 659 
 660         {
 661             char r = (char) vh.compareAndExchange('\u4567', '\u89AB');
 662             assertEquals(r, '\u0123', "failing compareAndExchange char");
 663             char x = (char) vh.get();
 664             assertEquals(x, '\u0123', "failing compareAndExchange char value");
 665         }
 666 
 667         {
 668             char r = (char) vh.compareAndExchangeAcquire('\u0123', '\u4567');
 669             assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
 670             char x = (char) vh.get();
 671             assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
 672         }
 673 
 674         {
 675             char r = (char) vh.compareAndExchangeAcquire('\u0123', '\u89AB');
 676             assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
 677             char x = (char) vh.get();
 678             assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
 679         }
 680 
 681         {
 682             char r = (char) vh.compareAndExchangeRelease('\u4567', '\u0123');
 683             assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
 684             char x = (char) vh.get();
 685             assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
 686         }
 687 
 688         {
 689             char r = (char) vh.compareAndExchangeRelease('\u4567', '\u89AB');
 690             assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
 691             char x = (char) vh.get();
 692             assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
 693         }
 694 
 695         {
 696             boolean success = false;
 697             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 698                 success = vh.weakCompareAndSetPlain('\u0123', '\u4567');
 699             }
 700             assertEquals(success, true, "weakCompareAndSetPlain char");
 701             char x = (char) vh.get();
 702             assertEquals(x, '\u4567', "weakCompareAndSetPlain char value");
 703         }
 704 
 705         {
 706             boolean success = false;
 707             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 708                 success = vh.weakCompareAndSetAcquire('\u4567', '\u0123');
 709             }
 710             assertEquals(success, true, "weakCompareAndSetAcquire char");
 711             char x = (char) vh.get();
 712             assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
 713         }
 714 
 715         {
 716             boolean success = false;
 717             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 718                 success = vh.weakCompareAndSetRelease('\u0123', '\u4567');
 719             }
 720             assertEquals(success, true, "weakCompareAndSetRelease char");
 721             char x = (char) vh.get();
 722             assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
 723         }
 724 
 725         {
 726             boolean success = false;
 727             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 728                 success = vh.weakCompareAndSet('\u4567', '\u0123');
 729             }
 730             assertEquals(success, true, "weakCompareAndSet char");
 731             char x = (char) vh.get();
 732             assertEquals(x, '\u0123', "weakCompareAndSet char");
 733         }
 734 
 735         // Compare set and get
 736         {
 737             vh.set('\u0123');
 738 
 739             char o = (char) vh.getAndSet('\u4567');
 740             assertEquals(o, '\u0123', "getAndSet char");
 741             char x = (char) vh.get();
 742             assertEquals(x, '\u4567', "getAndSet char value");
 743         }
 744 
 745         {
 746             vh.set('\u0123');
 747 
 748             char o = (char) vh.getAndSetAcquire('\u4567');
 749             assertEquals(o, '\u0123', "getAndSetAcquire char");
 750             char x = (char) vh.get();
 751             assertEquals(x, '\u4567', "getAndSetAcquire char value");
 752         }
 753 
 754         {
 755             vh.set('\u0123');
 756 
 757             char o = (char) vh.getAndSetRelease('\u4567');
 758             assertEquals(o, '\u0123', "getAndSetRelease char");
 759             char x = (char) vh.get();
 760             assertEquals(x, '\u4567', "getAndSetRelease char value");
 761         }
 762 
 763         // get and add, add and get
 764         {
 765             vh.set('\u0123');
 766 
 767             char o = (char) vh.getAndAdd('\u4567');
 768             assertEquals(o, '\u0123', "getAndAdd char");
 769             char x = (char) vh.get();
 770             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value");
 771         }
 772 
 773         {
 774             vh.set('\u0123');
 775 
 776             char o = (char) vh.getAndAddAcquire('\u4567');
 777             assertEquals(o, '\u0123', "getAndAddAcquire char");
 778             char x = (char) vh.get();
 779             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value");
 780         }
 781 
 782         {
 783             vh.set('\u0123');
 784 
 785             char o = (char) vh.getAndAddRelease('\u4567');
 786             assertEquals(o, '\u0123', "getAndAddReleasechar");
 787             char x = (char) vh.get();
 788             assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value");
 789         }
 790 
 791         // get and bitwise or
 792         {
 793             vh.set('\u0123');
 794 
 795             char o = (char) vh.getAndBitwiseOr('\u4567');
 796             assertEquals(o, '\u0123', "getAndBitwiseOr char");
 797             char x = (char) vh.get();
 798             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value");
 799         }
 800 
 801         {
 802             vh.set('\u0123');
 803 
 804             char o = (char) vh.getAndBitwiseOrAcquire('\u4567');
 805             assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char");
 806             char x = (char) vh.get();
 807             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value");
 808         }
 809 
 810         {
 811             vh.set('\u0123');
 812 
 813             char o = (char) vh.getAndBitwiseOrRelease('\u4567');
 814             assertEquals(o, '\u0123', "getAndBitwiseOrRelease char");
 815             char x = (char) vh.get();
 816             assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value");
 817         }
 818 
 819         // get and bitwise and
 820         {
 821             vh.set('\u0123');
 822 
 823             char o = (char) vh.getAndBitwiseAnd('\u4567');
 824             assertEquals(o, '\u0123', "getAndBitwiseAnd char");
 825             char x = (char) vh.get();
 826             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value");
 827         }
 828 
 829         {
 830             vh.set('\u0123');
 831 
 832             char o = (char) vh.getAndBitwiseAndAcquire('\u4567');
 833             assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char");
 834             char x = (char) vh.get();
 835             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value");
 836         }
 837 
 838         {
 839             vh.set('\u0123');
 840 
 841             char o = (char) vh.getAndBitwiseAndRelease('\u4567');
 842             assertEquals(o, '\u0123', "getAndBitwiseAndRelease char");
 843             char x = (char) vh.get();
 844             assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value");
 845         }
 846 
 847         // get and bitwise xor
 848         {
 849             vh.set('\u0123');
 850 
 851             char o = (char) vh.getAndBitwiseXor('\u4567');
 852             assertEquals(o, '\u0123', "getAndBitwiseXor char");
 853             char x = (char) vh.get();
 854             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value");
 855         }
 856 
 857         {
 858             vh.set('\u0123');
 859 
 860             char o = (char) vh.getAndBitwiseXorAcquire('\u4567');
 861             assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char");
 862             char x = (char) vh.get();
 863             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value");
 864         }
 865 
 866         {
 867             vh.set('\u0123');
 868 
 869             char o = (char) vh.getAndBitwiseXorRelease('\u4567');
 870             assertEquals(o, '\u0123', "getAndBitwiseXorRelease char");
 871             char x = (char) vh.get();
 872             assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value");
 873         }
 874     }
 875 
 876     static void testStaticFieldUnsupported(VarHandle vh) {
 877 
 878 
 879     }
 880 
 881 
 882     static void testArray(VarHandle vh) {
 883         char[] array = new char[10];
 884 
 885         for (int i = 0; i < array.length; i++) {
 886             // Plain
 887             {
 888                 vh.set(array, i, '\u0123');
 889                 char x = (char) vh.get(array, i);
 890                 assertEquals(x, '\u0123', "get char value");
 891             }
 892 
 893 
 894             // Volatile
 895             {
 896                 vh.setVolatile(array, i, '\u4567');
 897                 char x = (char) vh.getVolatile(array, i);
 898                 assertEquals(x, '\u4567', "setVolatile char value");
 899             }
 900 
 901             // Lazy
 902             {
 903                 vh.setRelease(array, i, '\u0123');
 904                 char x = (char) vh.getAcquire(array, i);
 905                 assertEquals(x, '\u0123', "setRelease char value");
 906             }
 907 
 908             // Opaque
 909             {
 910                 vh.setOpaque(array, i, '\u4567');
 911                 char x = (char) vh.getOpaque(array, i);
 912                 assertEquals(x, '\u4567', "setOpaque char value");
 913             }
 914 
 915             vh.set(array, i, '\u0123');
 916 
 917             // Compare
 918             {
 919                 boolean r = vh.compareAndSet(array, i, '\u0123', '\u4567');
 920                 assertEquals(r, true, "success compareAndSet char");
 921                 char x = (char) vh.get(array, i);
 922                 assertEquals(x, '\u4567', "success compareAndSet char value");
 923             }
 924 
 925             {
 926                 boolean r = vh.compareAndSet(array, i, '\u0123', '\u89AB');
 927                 assertEquals(r, false, "failing compareAndSet char");
 928                 char x = (char) vh.get(array, i);
 929                 assertEquals(x, '\u4567', "failing compareAndSet char value");
 930             }
 931 
 932             {
 933                 char r = (char) vh.compareAndExchange(array, i, '\u4567', '\u0123');
 934                 assertEquals(r, '\u4567', "success compareAndExchange char");
 935                 char x = (char) vh.get(array, i);
 936                 assertEquals(x, '\u0123', "success compareAndExchange char value");
 937             }
 938 
 939             {
 940                 char r = (char) vh.compareAndExchange(array, i, '\u4567', '\u89AB');
 941                 assertEquals(r, '\u0123', "failing compareAndExchange char");
 942                 char x = (char) vh.get(array, i);
 943                 assertEquals(x, '\u0123', "failing compareAndExchange char value");
 944             }
 945 
 946             {
 947                 char r = (char) vh.compareAndExchangeAcquire(array, i, '\u0123', '\u4567');
 948                 assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
 949                 char x = (char) vh.get(array, i);
 950                 assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
 951             }
 952 
 953             {
 954                 char r = (char) vh.compareAndExchangeAcquire(array, i, '\u0123', '\u89AB');
 955                 assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
 956                 char x = (char) vh.get(array, i);
 957                 assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
 958             }
 959 
 960             {
 961                 char r = (char) vh.compareAndExchangeRelease(array, i, '\u4567', '\u0123');
 962                 assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
 963                 char x = (char) vh.get(array, i);
 964                 assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
 965             }
 966 
 967             {
 968                 char r = (char) vh.compareAndExchangeRelease(array, i, '\u4567', '\u89AB');
 969                 assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
 970                 char x = (char) vh.get(array, i);
 971                 assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
 972             }
 973 
 974             {
 975                 boolean success = false;
 976                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 977                     success = vh.weakCompareAndSetPlain(array, i, '\u0123', '\u4567');
 978                 }
 979                 assertEquals(success, true, "weakCompareAndSetPlain char");
 980                 char x = (char) vh.get(array, i);
 981                 assertEquals(x, '\u4567', "weakCompareAndSetPlain char value");
 982             }
 983 
 984             {
 985                 boolean success = false;
 986                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 987                     success = vh.weakCompareAndSetAcquire(array, i, '\u4567', '\u0123');
 988                 }
 989                 assertEquals(success, true, "weakCompareAndSetAcquire char");
 990                 char x = (char) vh.get(array, i);
 991                 assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
 992             }
 993 
 994             {
 995                 boolean success = false;
 996                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
 997                     success = vh.weakCompareAndSetRelease(array, i, '\u0123', '\u4567');
 998                 }
 999                 assertEquals(success, true, "weakCompareAndSetRelease char");
1000                 char x = (char) vh.get(array, i);
1001                 assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
1002             }
1003 
1004             {
1005                 boolean success = false;
1006                 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
1007                     success = vh.weakCompareAndSet(array, i, '\u4567', '\u0123');
1008                 }
1009                 assertEquals(success, true, "weakCompareAndSet char");
1010                 char x = (char) vh.get(array, i);
1011                 assertEquals(x, '\u0123', "weakCompareAndSet char");
1012             }
1013 
1014             // Compare set and get
1015             {
1016                 vh.set(array, i, '\u0123');
1017 
1018                 char o = (char) vh.getAndSet(array, i, '\u4567');
1019                 assertEquals(o, '\u0123', "getAndSet char");
1020                 char x = (char) vh.get(array, i);
1021                 assertEquals(x, '\u4567', "getAndSet char value");
1022             }
1023 
1024             {
1025                 vh.set(array, i, '\u0123');
1026 
1027                 char o = (char) vh.getAndSetAcquire(array, i, '\u4567');
1028                 assertEquals(o, '\u0123', "getAndSetAcquire char");
1029                 char x = (char) vh.get(array, i);
1030                 assertEquals(x, '\u4567', "getAndSetAcquire char value");
1031             }
1032 
1033             {
1034                 vh.set(array, i, '\u0123');
1035 
1036                 char o = (char) vh.getAndSetRelease(array, i, '\u4567');
1037                 assertEquals(o, '\u0123', "getAndSetRelease char");
1038                 char x = (char) vh.get(array, i);
1039                 assertEquals(x, '\u4567', "getAndSetRelease char value");
1040             }
1041 
1042             // get and add, add and get
1043             {
1044                 vh.set(array, i, '\u0123');
1045 
1046                 char o = (char) vh.getAndAdd(array, i, '\u4567');
1047                 assertEquals(o, '\u0123', "getAndAdd char");
1048                 char x = (char) vh.get(array, i);
1049                 assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value");
1050             }
1051 
1052             {
1053                 vh.set(array, i, '\u0123');
1054 
1055                 char o = (char) vh.getAndAddAcquire(array, i, '\u4567');
1056                 assertEquals(o, '\u0123', "getAndAddAcquire char");
1057                 char x = (char) vh.get(array, i);
1058                 assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value");
1059             }
1060 
1061             {
1062                 vh.set(array, i, '\u0123');
1063 
1064                 char o = (char) vh.getAndAddRelease(array, i, '\u4567');
1065                 assertEquals(o, '\u0123', "getAndAddReleasechar");
1066                 char x = (char) vh.get(array, i);
1067                 assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value");
1068             }
1069 
1070             // get and bitwise or
1071             {
1072                 vh.set(array, i, '\u0123');
1073 
1074                 char o = (char) vh.getAndBitwiseOr(array, i, '\u4567');
1075                 assertEquals(o, '\u0123', "getAndBitwiseOr char");
1076                 char x = (char) vh.get(array, i);
1077                 assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value");
1078             }
1079 
1080             {
1081                 vh.set(array, i, '\u0123');
1082 
1083                 char o = (char) vh.getAndBitwiseOrAcquire(array, i, '\u4567');
1084                 assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char");
1085                 char x = (char) vh.get(array, i);
1086                 assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value");
1087             }
1088 
1089             {
1090                 vh.set(array, i, '\u0123');
1091 
1092                 char o = (char) vh.getAndBitwiseOrRelease(array, i, '\u4567');
1093                 assertEquals(o, '\u0123', "getAndBitwiseOrRelease char");
1094                 char x = (char) vh.get(array, i);
1095                 assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value");
1096             }
1097 
1098             // get and bitwise and
1099             {
1100                 vh.set(array, i, '\u0123');
1101 
1102                 char o = (char) vh.getAndBitwiseAnd(array, i, '\u4567');
1103                 assertEquals(o, '\u0123', "getAndBitwiseAnd char");
1104                 char x = (char) vh.get(array, i);
1105                 assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value");
1106             }
1107 
1108             {
1109                 vh.set(array, i, '\u0123');
1110 
1111                 char o = (char) vh.getAndBitwiseAndAcquire(array, i, '\u4567');
1112                 assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char");
1113                 char x = (char) vh.get(array, i);
1114                 assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value");
1115             }
1116 
1117             {
1118                 vh.set(array, i, '\u0123');
1119 
1120                 char o = (char) vh.getAndBitwiseAndRelease(array, i, '\u4567');
1121                 assertEquals(o, '\u0123', "getAndBitwiseAndRelease char");
1122                 char x = (char) vh.get(array, i);
1123                 assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value");
1124             }
1125 
1126             // get and bitwise xor
1127             {
1128                 vh.set(array, i, '\u0123');
1129 
1130                 char o = (char) vh.getAndBitwiseXor(array, i, '\u4567');
1131                 assertEquals(o, '\u0123', "getAndBitwiseXor char");
1132                 char x = (char) vh.get(array, i);
1133                 assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value");
1134             }
1135 
1136             {
1137                 vh.set(array, i, '\u0123');
1138 
1139                 char o = (char) vh.getAndBitwiseXorAcquire(array, i, '\u4567');
1140                 assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char");
1141                 char x = (char) vh.get(array, i);
1142                 assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value");
1143             }
1144 
1145             {
1146                 vh.set(array, i, '\u0123');
1147 
1148                 char o = (char) vh.getAndBitwiseXorRelease(array, i, '\u4567');
1149                 assertEquals(o, '\u0123', "getAndBitwiseXorRelease char");
1150                 char x = (char) vh.get(array, i);
1151                 assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value");
1152             }
1153         }
1154     }
1155 
1156     static void testArrayUnsupported(VarHandle vh) {
1157         char[] array = new char[10];
1158 
1159         int i = 0;
1160 
1161 
1162     }
1163 
1164     static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable {
1165         char[] array = new char[10];
1166 
1167         for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) {
1168             final int ci = i;
1169 
1170             checkIOOBE(() -> {
1171                 char x = (char) vh.get(array, ci);
1172             });
1173 
1174             checkIOOBE(() -> {
1175                 vh.set(array, ci, '\u0123');
1176             });
1177 
1178             checkIOOBE(() -> {
1179                 char x = (char) vh.getVolatile(array, ci);
1180             });
1181 
1182             checkIOOBE(() -> {
1183                 vh.setVolatile(array, ci, '\u0123');
1184             });
1185 
1186             checkIOOBE(() -> {
1187                 char x = (char) vh.getAcquire(array, ci);
1188             });
1189 
1190             checkIOOBE(() -> {
1191                 vh.setRelease(array, ci, '\u0123');
1192             });
1193 
1194             checkIOOBE(() -> {
1195                 char x = (char) vh.getOpaque(array, ci);
1196             });
1197 
1198             checkIOOBE(() -> {
1199                 vh.setOpaque(array, ci, '\u0123');
1200             });
1201 
1202             checkIOOBE(() -> {
1203                 boolean r = vh.compareAndSet(array, ci, '\u0123', '\u4567');
1204             });
1205 
1206             checkIOOBE(() -> {
1207                 char r = (char) vh.compareAndExchange(array, ci, '\u4567', '\u0123');
1208             });
1209 
1210             checkIOOBE(() -> {
1211                 char r = (char) vh.compareAndExchangeAcquire(array, ci, '\u4567', '\u0123');
1212             });
1213 
1214             checkIOOBE(() -> {
1215                 char r = (char) vh.compareAndExchangeRelease(array, ci, '\u4567', '\u0123');
1216             });
1217 
1218             checkIOOBE(() -> {
1219                 boolean r = vh.weakCompareAndSetPlain(array, ci, '\u0123', '\u4567');
1220             });
1221 
1222             checkIOOBE(() -> {
1223                 boolean r = vh.weakCompareAndSet(array, ci, '\u0123', '\u4567');
1224             });
1225 
1226             checkIOOBE(() -> {
1227                 boolean r = vh.weakCompareAndSetAcquire(array, ci, '\u0123', '\u4567');
1228             });
1229 
1230             checkIOOBE(() -> {
1231                 boolean r = vh.weakCompareAndSetRelease(array, ci, '\u0123', '\u4567');
1232             });
1233 
1234             checkIOOBE(() -> {
1235                 char o = (char) vh.getAndSet(array, ci, '\u0123');
1236             });
1237 
1238             checkIOOBE(() -> {
1239                 char o = (char) vh.getAndSetAcquire(array, ci, '\u0123');
1240             });
1241 
1242             checkIOOBE(() -> {
1243                 char o = (char) vh.getAndSetRelease(array, ci, '\u0123');
1244             });
1245 
1246             checkIOOBE(() -> {
1247                 char o = (char) vh.getAndAdd(array, ci, '\u0123');
1248             });
1249 
1250             checkIOOBE(() -> {
1251                 char o = (char) vh.getAndAddAcquire(array, ci, '\u0123');
1252             });
1253 
1254             checkIOOBE(() -> {
1255                 char o = (char) vh.getAndAddRelease(array, ci, '\u0123');
1256             });
1257 
1258             checkIOOBE(() -> {
1259                 char o = (char) vh.getAndBitwiseOr(array, ci, '\u0123');
1260             });
1261 
1262             checkIOOBE(() -> {
1263                 char o = (char) vh.getAndBitwiseOrAcquire(array, ci, '\u0123');
1264             });
1265 
1266             checkIOOBE(() -> {
1267                 char o = (char) vh.getAndBitwiseOrRelease(array, ci, '\u0123');
1268             });
1269 
1270             checkIOOBE(() -> {
1271                 char o = (char) vh.getAndBitwiseAnd(array, ci, '\u0123');
1272             });
1273 
1274             checkIOOBE(() -> {
1275                 char o = (char) vh.getAndBitwiseAndAcquire(array, ci, '\u0123');
1276             });
1277 
1278             checkIOOBE(() -> {
1279                 char o = (char) vh.getAndBitwiseAndRelease(array, ci, '\u0123');
1280             });
1281 
1282             checkIOOBE(() -> {
1283                 char o = (char) vh.getAndBitwiseXor(array, ci, '\u0123');
1284             });
1285 
1286             checkIOOBE(() -> {
1287                 char o = (char) vh.getAndBitwiseXorAcquire(array, ci, '\u0123');
1288             });
1289 
1290             checkIOOBE(() -> {
1291                 char o = (char) vh.getAndBitwiseXorRelease(array, ci, '\u0123');
1292             });
1293         }
1294     }
1295 
1296 }
1297