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