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