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