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