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