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