1 /* 2 * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @comment Set CompileThresholdScaling to 0.1 so that the warmup loop sets to 2000 iterations 27 * to hit compilation thresholds 28 * @run testng/othervm -Diters=2000 -XX:CompileThresholdScaling=0.1 VarHandleTestMethodHandleAccessBoolean 29 */ 30 31 import org.testng.annotations.BeforeClass; 32 import org.testng.annotations.DataProvider; 33 import org.testng.annotations.Test; 34 35 import java.lang.invoke.MethodHandle; 36 import java.lang.invoke.MethodHandles; 37 import java.lang.invoke.VarHandle; 38 import java.util.ArrayList; 39 import java.util.Arrays; 40 import java.util.List; 41 42 import static org.testng.Assert.*; 43 44 public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { 45 static final boolean static_final_v = true; 46 47 static boolean static_v; 48 49 final boolean final_v = true; 50 51 boolean v; 52 53 VarHandle vhFinalField; 54 55 VarHandle vhField; 56 57 VarHandle vhStaticField; 58 59 VarHandle vhStaticFinalField; 60 61 VarHandle vhArray; 62 63 @BeforeClass 64 public void setup() throws Exception { 65 vhFinalField = MethodHandles.lookup().findVarHandle( 66 VarHandleTestMethodHandleAccessBoolean.class, "final_v", boolean.class); 67 68 vhField = MethodHandles.lookup().findVarHandle( 69 VarHandleTestMethodHandleAccessBoolean.class, "v", boolean.class); 70 71 vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle( 72 VarHandleTestMethodHandleAccessBoolean.class, "static_final_v", boolean.class); 73 74 vhStaticField = MethodHandles.lookup().findStaticVarHandle( 75 VarHandleTestMethodHandleAccessBoolean.class, "static_v", boolean.class); 76 77 vhArray = MethodHandles.arrayElementVarHandle(boolean[].class); 78 } 79 80 81 @DataProvider 82 public Object[][] accessTestCaseProvider() throws Exception { 83 List<AccessTestCase<?>> cases = new ArrayList<>(); 84 85 for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { 86 cases.add(new MethodHandleAccessTestCase("Instance field", 87 vhField, f, hs -> testInstanceField(this, hs))); 88 cases.add(new MethodHandleAccessTestCase("Instance field unsupported", 89 vhField, f, hs -> testInstanceFieldUnsupported(this, hs), 90 false)); 91 92 cases.add(new MethodHandleAccessTestCase("Static field", 93 vhStaticField, f, VarHandleTestMethodHandleAccessBoolean::testStaticField)); 94 cases.add(new MethodHandleAccessTestCase("Static field unsupported", 95 vhStaticField, f, VarHandleTestMethodHandleAccessBoolean::testStaticFieldUnsupported, 96 false)); 97 98 cases.add(new MethodHandleAccessTestCase("Array", 99 vhArray, f, VarHandleTestMethodHandleAccessBoolean::testArray)); 100 cases.add(new MethodHandleAccessTestCase("Array unsupported", 101 vhArray, f, VarHandleTestMethodHandleAccessBoolean::testArrayUnsupported, 102 false)); 103 cases.add(new MethodHandleAccessTestCase("Array index out of bounds", 104 vhArray, f, VarHandleTestMethodHandleAccessBoolean::testArrayIndexOutOfBounds, 105 false)); 106 } 107 108 // Work around issue with jtreg summary reporting which truncates 109 // the String result of Object.toString to 30 characters, hence 110 // the first dummy argument 111 return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new); 112 } 113 114 @Test(dataProvider = "accessTestCaseProvider") 115 public <T> void testAccess(String desc, AccessTestCase<T> atc) throws Throwable { 116 T t = atc.get(); 117 int iters = atc.requiresLoop() ? ITERS : 1; 118 for (int c = 0; c < iters; c++) { 119 atc.testAccess(t); 120 } 121 } 122 123 124 static void testInstanceField(VarHandleTestMethodHandleAccessBoolean recv, Handles hs) throws Throwable { 125 // Plain 126 { 127 hs.get(TestAccessMode.SET).invokeExact(recv, true); 128 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 129 assertEquals(x, true, "set boolean value"); 130 } 131 132 133 // Volatile 134 { 135 hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, false); 136 boolean x = (boolean) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv); 137 assertEquals(x, false, "setVolatile boolean value"); 138 } 139 140 // Lazy 141 { 142 hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, true); 143 boolean x = (boolean) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv); 144 assertEquals(x, true, "setRelease boolean value"); 145 } 146 147 // Opaque 148 { 149 hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, false); 150 boolean x = (boolean) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv); 151 assertEquals(x, false, "setOpaque boolean value"); 152 } 153 154 hs.get(TestAccessMode.SET).invokeExact(recv, true); 155 156 // Compare 157 { 158 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, true, false); 159 assertEquals(r, true, "success compareAndSet boolean"); 160 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 161 assertEquals(x, false, "success compareAndSet boolean value"); 162 } 163 164 { 165 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, true, false); 166 assertEquals(r, false, "failing compareAndSet boolean"); 167 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 168 assertEquals(x, false, "failing compareAndSet boolean value"); 169 } 170 171 { 172 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(recv, false, true); 173 assertEquals(r, false, "success compareAndExchange boolean"); 174 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 175 assertEquals(x, true, "success compareAndExchange boolean value"); 176 } 177 178 { 179 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(recv, false, false); 180 assertEquals(r, true, "failing compareAndExchange boolean"); 181 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 182 assertEquals(x, true, "failing compareAndExchange boolean value"); 183 } 184 185 { 186 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, true, false); 187 assertEquals(r, true, "success compareAndExchangeAcquire boolean"); 188 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 189 assertEquals(x, false, "success compareAndExchangeAcquire boolean value"); 190 } 191 192 { 193 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, true, false); 194 assertEquals(r, false, "failing compareAndExchangeAcquire boolean"); 195 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 196 assertEquals(x, false, "failing compareAndExchangeAcquire boolean value"); 197 } 198 199 { 200 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, false, true); 201 assertEquals(r, false, "success compareAndExchangeRelease boolean"); 202 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 203 assertEquals(x, true, "success compareAndExchangeRelease boolean value"); 204 } 205 206 { 207 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, false, false); 208 assertEquals(r, true, "failing compareAndExchangeRelease boolean"); 209 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 210 assertEquals(x, true, "failing compareAndExchangeRelease boolean value"); 211 } 212 213 { 214 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN); 215 boolean success = false; 216 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 217 success = (boolean) mh.invokeExact(recv, true, false); 218 if (!success) weakDelay(); 219 } 220 assertEquals(success, true, "success weakCompareAndSetPlain boolean"); 221 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 222 assertEquals(x, false, "success weakCompareAndSetPlain boolean value"); 223 } 224 225 { 226 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, true, false); 227 assertEquals(success, false, "failing weakCompareAndSetPlain boolean"); 228 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 229 assertEquals(x, false, "failing weakCompareAndSetPlain boolean value"); 230 } 231 232 { 233 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE); 234 boolean success = false; 235 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 236 success = (boolean) mh.invokeExact(recv, false, true); 237 if (!success) weakDelay(); 238 } 239 assertEquals(success, true, "success weakCompareAndSetAcquire boolean"); 240 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 241 assertEquals(x, true, "success weakCompareAndSetAcquire boolean"); 242 } 243 244 { 245 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, false, false); 246 assertEquals(success, false, "failing weakCompareAndSetAcquire boolean"); 247 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 248 assertEquals(x, true, "failing weakCompareAndSetAcquire boolean value"); 249 } 250 251 { 252 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE); 253 boolean success = false; 254 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 255 success = (boolean) mh.invokeExact(recv, true, false); 256 if (!success) weakDelay(); 257 } 258 assertEquals(success, true, "success weakCompareAndSetRelease boolean"); 259 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 260 assertEquals(x, false, "success weakCompareAndSetRelease boolean"); 261 } 262 263 { 264 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, true, false); 265 assertEquals(success, false, "failing weakCompareAndSetRelease boolean"); 266 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 267 assertEquals(x, false, "failing weakCompareAndSetRelease boolean value"); 268 } 269 270 { 271 boolean success = false; 272 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET); 273 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 274 success = (boolean) mh.invokeExact(recv, false, true); 275 if (!success) weakDelay(); 276 } 277 assertEquals(success, true, "success weakCompareAndSet boolean"); 278 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 279 assertEquals(x, true, "success weakCompareAndSet boolean"); 280 } 281 282 { 283 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, false, false); 284 assertEquals(success, false, "failing weakCompareAndSet boolean"); 285 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 286 assertEquals(x, true, "failing weakCompareAndSet boolean value"); 287 } 288 289 // Compare set and get 290 { 291 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, false); 292 assertEquals(o, true, "getAndSet boolean"); 293 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 294 assertEquals(x, false, "getAndSet boolean value"); 295 } 296 297 298 // get and bitwise or 299 { 300 hs.get(TestAccessMode.SET).invokeExact(recv, true); 301 302 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, false); 303 assertEquals(o, true, "getAndBitwiseOr boolean"); 304 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 305 assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); 306 } 307 308 { 309 hs.get(TestAccessMode.SET).invokeExact(recv, true); 310 311 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, false); 312 assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); 313 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 314 assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); 315 } 316 317 { 318 hs.get(TestAccessMode.SET).invokeExact(recv, true); 319 320 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, false); 321 assertEquals(o, true, "getAndBitwiseOrRelease boolean"); 322 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 323 assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); 324 } 325 326 // get and bitwise and 327 { 328 hs.get(TestAccessMode.SET).invokeExact(recv, true); 329 330 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, false); 331 assertEquals(o, true, "getAndBitwiseAnd boolean"); 332 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 333 assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); 334 } 335 336 { 337 hs.get(TestAccessMode.SET).invokeExact(recv, true); 338 339 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, false); 340 assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); 341 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 342 assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); 343 } 344 345 { 346 hs.get(TestAccessMode.SET).invokeExact(recv, true); 347 348 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, false); 349 assertEquals(o, true, "getAndBitwiseAndRelease boolean"); 350 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 351 assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); 352 } 353 354 // get and bitwise xor 355 { 356 hs.get(TestAccessMode.SET).invokeExact(recv, true); 357 358 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, false); 359 assertEquals(o, true, "getAndBitwiseXor boolean"); 360 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 361 assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); 362 } 363 364 { 365 hs.get(TestAccessMode.SET).invokeExact(recv, true); 366 367 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, false); 368 assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); 369 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 370 assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); 371 } 372 373 { 374 hs.get(TestAccessMode.SET).invokeExact(recv, true); 375 376 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, false); 377 assertEquals(o, true, "getAndBitwiseXorRelease boolean"); 378 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); 379 assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); 380 } 381 } 382 383 static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessBoolean recv, Handles hs) throws Throwable { 384 385 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { 386 checkUOE(am, () -> { 387 boolean r = (boolean) hs.get(am).invokeExact(recv, true); 388 }); 389 } 390 391 } 392 393 394 static void testStaticField(Handles hs) throws Throwable { 395 // Plain 396 { 397 hs.get(TestAccessMode.SET).invokeExact(true); 398 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 399 assertEquals(x, true, "set boolean value"); 400 } 401 402 403 // Volatile 404 { 405 hs.get(TestAccessMode.SET_VOLATILE).invokeExact(false); 406 boolean x = (boolean) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(); 407 assertEquals(x, false, "setVolatile boolean value"); 408 } 409 410 // Lazy 411 { 412 hs.get(TestAccessMode.SET_RELEASE).invokeExact(true); 413 boolean x = (boolean) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(); 414 assertEquals(x, true, "setRelease boolean value"); 415 } 416 417 // Opaque 418 { 419 hs.get(TestAccessMode.SET_OPAQUE).invokeExact(false); 420 boolean x = (boolean) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(); 421 assertEquals(x, false, "setOpaque boolean value"); 422 } 423 424 hs.get(TestAccessMode.SET).invokeExact(true); 425 426 // Compare 427 { 428 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(true, false); 429 assertEquals(r, true, "success compareAndSet boolean"); 430 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 431 assertEquals(x, false, "success compareAndSet boolean value"); 432 } 433 434 { 435 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(true, false); 436 assertEquals(r, false, "failing compareAndSet boolean"); 437 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 438 assertEquals(x, false, "failing compareAndSet boolean value"); 439 } 440 441 { 442 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(false, true); 443 assertEquals(r, false, "success compareAndExchange boolean"); 444 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 445 assertEquals(x, true, "success compareAndExchange boolean value"); 446 } 447 448 { 449 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(false, false); 450 assertEquals(r, true, "failing compareAndExchange boolean"); 451 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 452 assertEquals(x, true, "failing compareAndExchange boolean value"); 453 } 454 455 { 456 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(true, false); 457 assertEquals(r, true, "success compareAndExchangeAcquire boolean"); 458 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 459 assertEquals(x, false, "success compareAndExchangeAcquire boolean value"); 460 } 461 462 { 463 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(true, false); 464 assertEquals(r, false, "failing compareAndExchangeAcquire boolean"); 465 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 466 assertEquals(x, false, "failing compareAndExchangeAcquire boolean value"); 467 } 468 469 { 470 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(false, true); 471 assertEquals(r, false, "success compareAndExchangeRelease boolean"); 472 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 473 assertEquals(x, true, "success compareAndExchangeRelease boolean value"); 474 } 475 476 { 477 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(false, false); 478 assertEquals(r, true, "failing compareAndExchangeRelease boolean"); 479 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 480 assertEquals(x, true, "failing compareAndExchangeRelease boolean value"); 481 } 482 483 { 484 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN); 485 boolean success = false; 486 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 487 success = (boolean) mh.invokeExact(true, false); 488 if (!success) weakDelay(); 489 } 490 assertEquals(success, true, "success weakCompareAndSetPlain boolean"); 491 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 492 assertEquals(x, false, "success weakCompareAndSetPlain boolean value"); 493 } 494 495 { 496 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(true, false); 497 assertEquals(success, false, "failing weakCompareAndSetPlain boolean"); 498 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 499 assertEquals(x, false, "failing weakCompareAndSetPlain boolean value"); 500 } 501 502 { 503 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE); 504 boolean success = false; 505 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 506 success = (boolean) mh.invokeExact(false, true); 507 if (!success) weakDelay(); 508 } 509 assertEquals(success, true, "success weakCompareAndSetAcquire boolean"); 510 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 511 assertEquals(x, true, "success weakCompareAndSetAcquire boolean"); 512 } 513 514 { 515 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE); 516 boolean success = (boolean) mh.invokeExact(false, false); 517 assertEquals(success, false, "failing weakCompareAndSetAcquire boolean"); 518 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 519 assertEquals(x, true, "failing weakCompareAndSetAcquire boolean value"); 520 } 521 522 { 523 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE); 524 boolean success = false; 525 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 526 success = (boolean) mh.invokeExact(true, false); 527 if (!success) weakDelay(); 528 } 529 assertEquals(success, true, "success weakCompareAndSetRelease boolean"); 530 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 531 assertEquals(x, false, "success weakCompareAndSetRelease boolean"); 532 } 533 534 { 535 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(true, false); 536 assertEquals(success, false, "failing weakCompareAndSetRelease boolean"); 537 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 538 assertEquals(x, false, "failing weakCompareAndSetRelease boolean value"); 539 } 540 541 { 542 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET); 543 boolean success = false; 544 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 545 success = (boolean) mh.invokeExact(false, true); 546 if (!success) weakDelay(); 547 } 548 assertEquals(success, true, "success weakCompareAndSet boolean"); 549 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 550 assertEquals(x, true, "success weakCompareAndSet boolean"); 551 } 552 553 { 554 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(false, false); 555 assertEquals(success, false, "failing weakCompareAndSet boolean"); 556 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 557 assertEquals(x, true, "failing weakCompareAndSetRe boolean value"); 558 } 559 560 // Compare set and get 561 { 562 hs.get(TestAccessMode.SET).invokeExact(true); 563 564 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(false); 565 assertEquals(o, true, "getAndSet boolean"); 566 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 567 assertEquals(x, false, "getAndSet boolean value"); 568 } 569 570 // Compare set and get 571 { 572 hs.get(TestAccessMode.SET).invokeExact(true); 573 574 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(false); 575 assertEquals(o, true, "getAndSetAcquire boolean"); 576 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 577 assertEquals(x, false, "getAndSetAcquire boolean value"); 578 } 579 580 // Compare set and get 581 { 582 hs.get(TestAccessMode.SET).invokeExact(true); 583 584 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(false); 585 assertEquals(o, true, "getAndSetRelease boolean"); 586 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 587 assertEquals(x, false, "getAndSetRelease boolean value"); 588 } 589 590 591 // get and bitwise or 592 { 593 hs.get(TestAccessMode.SET).invokeExact(true); 594 595 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(false); 596 assertEquals(o, true, "getAndBitwiseOr boolean"); 597 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 598 assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); 599 } 600 601 { 602 hs.get(TestAccessMode.SET).invokeExact(true); 603 604 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(false); 605 assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); 606 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 607 assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); 608 } 609 610 { 611 hs.get(TestAccessMode.SET).invokeExact(true); 612 613 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(false); 614 assertEquals(o, true, "getAndBitwiseOrRelease boolean"); 615 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 616 assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); 617 } 618 619 // get and bitwise and 620 { 621 hs.get(TestAccessMode.SET).invokeExact(true); 622 623 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(false); 624 assertEquals(o, true, "getAndBitwiseAnd boolean"); 625 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 626 assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); 627 } 628 629 { 630 hs.get(TestAccessMode.SET).invokeExact(true); 631 632 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(false); 633 assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); 634 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 635 assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); 636 } 637 638 { 639 hs.get(TestAccessMode.SET).invokeExact(true); 640 641 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(false); 642 assertEquals(o, true, "getAndBitwiseAndRelease boolean"); 643 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 644 assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); 645 } 646 647 // get and bitwise xor 648 { 649 hs.get(TestAccessMode.SET).invokeExact(true); 650 651 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(false); 652 assertEquals(o, true, "getAndBitwiseXor boolean"); 653 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 654 assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); 655 } 656 657 { 658 hs.get(TestAccessMode.SET).invokeExact(true); 659 660 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(false); 661 assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); 662 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 663 assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); 664 } 665 666 { 667 hs.get(TestAccessMode.SET).invokeExact(true); 668 669 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(false); 670 assertEquals(o, true, "getAndBitwiseXorRelease boolean"); 671 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); 672 assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); 673 } 674 } 675 676 static void testStaticFieldUnsupported(Handles hs) throws Throwable { 677 678 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { 679 checkUOE(am, () -> { 680 boolean r = (boolean) hs.get(am).invokeExact(true); 681 }); 682 } 683 684 } 685 686 687 static void testArray(Handles hs) throws Throwable { 688 boolean[] array = new boolean[10]; 689 690 for (int i = 0; i < array.length; i++) { 691 // Plain 692 { 693 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 694 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 695 assertEquals(x, true, "get boolean value"); 696 } 697 698 699 // Volatile 700 { 701 hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, false); 702 boolean x = (boolean) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i); 703 assertEquals(x, false, "setVolatile boolean value"); 704 } 705 706 // Lazy 707 { 708 hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, true); 709 boolean x = (boolean) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i); 710 assertEquals(x, true, "setRelease boolean value"); 711 } 712 713 // Opaque 714 { 715 hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, false); 716 boolean x = (boolean) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i); 717 assertEquals(x, false, "setOpaque boolean value"); 718 } 719 720 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 721 722 // Compare 723 { 724 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, true, false); 725 assertEquals(r, true, "success compareAndSet boolean"); 726 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 727 assertEquals(x, false, "success compareAndSet boolean value"); 728 } 729 730 { 731 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, true, false); 732 assertEquals(r, false, "failing compareAndSet boolean"); 733 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 734 assertEquals(x, false, "failing compareAndSet boolean value"); 735 } 736 737 { 738 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(array, i, false, true); 739 assertEquals(r, false, "success compareAndExchange boolean"); 740 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 741 assertEquals(x, true, "success compareAndExchange boolean value"); 742 } 743 744 { 745 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE).invokeExact(array, i, false, false); 746 assertEquals(r, true, "failing compareAndExchange boolean"); 747 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 748 assertEquals(x, true, "failing compareAndExchange boolean value"); 749 } 750 751 { 752 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, true, false); 753 assertEquals(r, true, "success compareAndExchangeAcquire boolean"); 754 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 755 assertEquals(x, false, "success compareAndExchangeAcquire boolean value"); 756 } 757 758 { 759 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, true, false); 760 assertEquals(r, false, "failing compareAndExchangeAcquire boolean"); 761 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 762 assertEquals(x, false, "failing compareAndExchangeAcquire boolean value"); 763 } 764 765 { 766 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, false, true); 767 assertEquals(r, false, "success compareAndExchangeRelease boolean"); 768 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 769 assertEquals(x, true, "success compareAndExchangeRelease boolean value"); 770 } 771 772 { 773 boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, false, false); 774 assertEquals(r, true, "failing compareAndExchangeRelease boolean"); 775 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 776 assertEquals(x, true, "failing compareAndExchangeRelease boolean value"); 777 } 778 779 { 780 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN); 781 boolean success = false; 782 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 783 success = (boolean) mh.invokeExact(array, i, true, false); 784 if (!success) weakDelay(); 785 } 786 assertEquals(success, true, "success weakCompareAndSetPlain boolean"); 787 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 788 assertEquals(x, false, "success weakCompareAndSetPlain boolean value"); 789 } 790 791 { 792 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, true, false); 793 assertEquals(success, false, "failing weakCompareAndSetPlain boolean"); 794 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 795 assertEquals(x, false, "failing weakCompareAndSetPlain boolean value"); 796 } 797 798 { 799 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE); 800 boolean success = false; 801 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 802 success = (boolean) mh.invokeExact(array, i, false, true); 803 if (!success) weakDelay(); 804 } 805 assertEquals(success, true, "success weakCompareAndSetAcquire boolean"); 806 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 807 assertEquals(x, true, "success weakCompareAndSetAcquire boolean"); 808 } 809 810 { 811 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, false, false); 812 assertEquals(success, false, "failing weakCompareAndSetAcquire boolean"); 813 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 814 assertEquals(x, true, "failing weakCompareAndSetAcquire boolean value"); 815 } 816 817 { 818 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE); 819 boolean success = false; 820 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 821 success = (boolean) mh.invokeExact(array, i, true, false); 822 if (!success) weakDelay(); 823 } 824 assertEquals(success, true, "success weakCompareAndSetRelease boolean"); 825 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 826 assertEquals(x, false, "success weakCompareAndSetRelease boolean"); 827 } 828 829 { 830 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, true, false); 831 assertEquals(success, false, "failing weakCompareAndSetAcquire boolean"); 832 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 833 assertEquals(x, false, "failing weakCompareAndSetAcquire boolean value"); 834 } 835 836 { 837 MethodHandle mh = hs.get(TestAccessMode.WEAK_COMPARE_AND_SET); 838 boolean success = false; 839 for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { 840 success = (boolean) mh.invokeExact(array, i, false, true); 841 if (!success) weakDelay(); 842 } 843 assertEquals(success, true, "success weakCompareAndSet boolean"); 844 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 845 assertEquals(x, true, "success weakCompareAndSet boolean"); 846 } 847 848 { 849 boolean success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, false, false); 850 assertEquals(success, false, "failing weakCompareAndSet boolean"); 851 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 852 assertEquals(x, true, "failing weakCompareAndSet boolean value"); 853 } 854 855 // Compare set and get 856 { 857 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 858 859 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, false); 860 assertEquals(o, true, "getAndSet boolean"); 861 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 862 assertEquals(x, false, "getAndSet boolean value"); 863 } 864 865 { 866 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 867 868 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, false); 869 assertEquals(o, true, "getAndSetAcquire boolean"); 870 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 871 assertEquals(x, false, "getAndSetAcquire boolean value"); 872 } 873 874 { 875 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 876 877 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, false); 878 assertEquals(o, true, "getAndSetRelease boolean"); 879 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 880 assertEquals(x, false, "getAndSetRelease boolean value"); 881 } 882 883 884 // get and bitwise or 885 { 886 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 887 888 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, false); 889 assertEquals(o, true, "getAndBitwiseOr boolean"); 890 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 891 assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); 892 } 893 894 { 895 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 896 897 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, false); 898 assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); 899 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 900 assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); 901 } 902 903 { 904 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 905 906 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, false); 907 assertEquals(o, true, "getAndBitwiseOrRelease boolean"); 908 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 909 assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); 910 } 911 912 // get and bitwise and 913 { 914 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 915 916 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, false); 917 assertEquals(o, true, "getAndBitwiseAnd boolean"); 918 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 919 assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); 920 } 921 922 { 923 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 924 925 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, false); 926 assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); 927 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 928 assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); 929 } 930 931 { 932 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 933 934 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, false); 935 assertEquals(o, true, "getAndBitwiseAndRelease boolean"); 936 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 937 assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); 938 } 939 940 // get and bitwise xor 941 { 942 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 943 944 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, false); 945 assertEquals(o, true, "getAndBitwiseXor boolean"); 946 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 947 assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); 948 } 949 950 { 951 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 952 953 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, false); 954 assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); 955 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 956 assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); 957 } 958 959 { 960 hs.get(TestAccessMode.SET).invokeExact(array, i, true); 961 962 boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, false); 963 assertEquals(o, true, "getAndBitwiseXorRelease boolean"); 964 boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); 965 assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); 966 } 967 } 968 } 969 970 static void testArrayUnsupported(Handles hs) throws Throwable { 971 boolean[] array = new boolean[10]; 972 973 final int i = 0; 974 975 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { 976 checkUOE(am, () -> { 977 boolean o = (boolean) hs.get(am).invokeExact(array, i, true); 978 }); 979 } 980 981 } 982 983 static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { 984 boolean[] array = new boolean[10]; 985 986 for (int i : new int[]{-1, Integer.MIN_VALUE, 10, 11, Integer.MAX_VALUE}) { 987 final int ci = i; 988 989 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { 990 checkAIOOBE(am, () -> { 991 boolean x = (boolean) hs.get(am).invokeExact(array, ci); 992 }); 993 } 994 995 for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { 996 checkAIOOBE(am, () -> { 997 hs.get(am).invokeExact(array, ci, true); 998 }); 999 } 1000 1001 for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { 1002 checkAIOOBE(am, () -> { 1003 boolean r = (boolean) hs.get(am).invokeExact(array, ci, true, false); 1004 }); 1005 } 1006 1007 for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { 1008 checkAIOOBE(am, () -> { 1009 boolean r = (boolean) hs.get(am).invokeExact(array, ci, false, true); 1010 }); 1011 } 1012 1013 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { 1014 checkAIOOBE(am, () -> { 1015 boolean o = (boolean) hs.get(am).invokeExact(array, ci, true); 1016 }); 1017 } 1018 1019 1020 for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { 1021 checkAIOOBE(am, () -> { 1022 boolean o = (boolean) hs.get(am).invokeExact(array, ci, false); 1023 }); 1024 } 1025 } 1026 } 1027 } 1028