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