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