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