Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/test/functional/Jsr292/src/com/ibm/j9/jsr292/FoldArgumentsTest.java
6007 views
1
/*******************************************************************************
2
* Copyright (c) 2014, 2019 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
package com.ibm.j9.jsr292;
23
24
import org.testng.annotations.Test;
25
import org.testng.AssertJUnit;
26
import static java.lang.invoke.MethodType.methodType;
27
28
import java.lang.invoke.MethodHandle;
29
import java.lang.invoke.MethodHandles;
30
import java.lang.invoke.MethodType;
31
import java.lang.invoke.WrongMethodTypeException;
32
33
/*
34
* Tests MethodHandles.foldArguments() with the following FieldTypes for (Parameter/Return Descriptors): Z, B, S, C, I, F, J, D, Ljava/lang/Double;
35
*
36
* For each FieldType, MethodHandles.foldArguments() is tested for boundary and intermediate conditions.
37
*
38
* Example:
39
*
40
* Let FieldType = D
41
*
42
* Tests MethodHandles.foldArguments() with the following FoldHandle.next method descriptor:
43
* (DDDDD)D
44
*
45
* Tests MethodHandles.foldArguments() with the following FoldHandle.combiner method descriptor variants:
46
* ()D
47
* (D)D
48
* (DD)D
49
* (DDD)D
50
* (DDDD)D
51
* (DDDD)V
52
*/
53
public class FoldArgumentsTest {
54
private final static byte constByte1 = (byte) -111;
55
private final static byte constByte2 = (byte) -61;
56
private final static byte constByte3 = (byte) -83;
57
private final static byte constByte4 = (byte) 84;
58
private final static short constShort1 = (short) -12096;
59
private final static short constShort2 = (short) -21510;
60
private final static short constShort3 = (short) -1622;
61
private final static short constShort4 = (short) -19784;
62
private final static char constCharacter1 = (char) 3763;
63
private final static char constCharacter2 = (char) 31911;
64
private final static char constCharacter3 = (char) 58509;
65
private final static char constCharacter4 = (char) 55609;
66
private final static int constInteger1 = (int) -491651072;
67
private final static int constInteger2 = (int) -1993736192;
68
private final static int constInteger3 = (int) 1213988863;
69
private final static int constInteger4 = (int) 326893567;
70
private final static long constLong1 = (long) 1.26663739519795e+018;
71
private final static long constLong2 = (long) 4.21368040135852e+018;
72
private final static long constLong3 = (long) 8.94696360972491e+018;
73
private final static long constLong4 = (long) 1.20527585027503e+018;
74
private final static float constFloat1 = (float) 2.29572201887512e+038F;
75
private final static float constFloat2 = (float) 6.12483306976318e+037F;
76
private final static float constFloat3 = (float) 1.53640056404114e+038F;
77
private final static float constFloat4 = (float) 6.22037132720947e+036F;
78
private final static double constDouble1 = (double) 1.10819706189633e+307;
79
private final static double constDouble2 = (double) 1.78024726032355e+307;
80
private final static double constDouble3 = (double) 6.78194657384276e+307;
81
private final static double constDouble4 = (double) 7.33110759312901e+307;
82
private final static boolean constBoolMax = true;
83
private final static boolean constBoolMin = false;
84
85
/* Test foldArguments: Combiner's data-type -> byte */
86
@Test(groups = { "level.extended" })
87
public void test_foldArguments_Byte() throws WrongMethodTypeException, Throwable {
88
MethodType nextMT = methodType(byte.class, byte.class, byte.class, byte.class, byte.class, byte.class);
89
MethodHandle mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "nextByte", nextMT);
90
91
MethodType combinerMT = methodType(byte.class);
92
MethodHandle mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
93
94
/* Verify Byte.Max_VALUE Boundary Condition */
95
MethodHandle foldMH = MethodHandles.foldArguments(mh1, mh2);
96
AssertJUnit.assertEquals(Byte.MAX_VALUE, (byte) foldMH.invokeExact(constByte1, constByte2, constByte3, constByte4));
97
98
combinerMT = methodType(byte.class, byte.class);
99
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
100
foldMH = MethodHandles.foldArguments(mh1, mh2);
101
AssertJUnit.assertEquals(Byte.MAX_VALUE, (byte) foldMH.invokeExact(Byte.MAX_VALUE, constByte2, constByte3, constByte4));
102
103
combinerMT = methodType(byte.class, byte.class, byte.class);
104
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
105
foldMH = MethodHandles.foldArguments(mh1, mh2);
106
AssertJUnit.assertEquals(Byte.MAX_VALUE, (byte) foldMH.invokeExact(constByte1, Byte.MAX_VALUE, constByte3, constByte4));
107
108
combinerMT = methodType(byte.class, byte.class, byte.class, byte.class);
109
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
110
foldMH = MethodHandles.foldArguments(mh1, mh2);
111
AssertJUnit.assertEquals(Byte.MAX_VALUE, (byte) foldMH.invokeExact(constByte1, constByte2, Byte.MAX_VALUE, constByte4));
112
113
combinerMT = methodType(byte.class, byte.class, byte.class, byte.class, byte.class);
114
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
115
foldMH = MethodHandles.foldArguments(mh1, mh2);
116
AssertJUnit.assertEquals(Byte.MAX_VALUE, (byte) foldMH.invokeExact(constByte1, constByte2, constByte3, Byte.MAX_VALUE));
117
118
/* Verify Byte.MIN_VALUE boundary condition */
119
combinerMT = methodType(byte.class, byte.class);
120
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
121
foldMH = MethodHandles.foldArguments(mh1, mh2);
122
AssertJUnit.assertEquals(Byte.MIN_VALUE, (byte) foldMH.invokeExact(Byte.MIN_VALUE, constByte2, constByte3, constByte4));
123
124
combinerMT = methodType(byte.class, byte.class, byte.class);
125
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
126
foldMH = MethodHandles.foldArguments(mh1, mh2);
127
AssertJUnit.assertEquals(constByte1, (byte) foldMH.invokeExact(constByte1, Byte.MIN_VALUE, constByte3, constByte4));
128
129
combinerMT = methodType(byte.class, byte.class, byte.class, byte.class);
130
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
131
foldMH = MethodHandles.foldArguments(mh1, mh2);
132
AssertJUnit.assertEquals(constByte2, (byte) foldMH.invokeExact(constByte1, constByte2, Byte.MIN_VALUE, constByte4));
133
134
combinerMT = methodType(byte.class, byte.class, byte.class, byte.class, byte.class);
135
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
136
foldMH = MethodHandles.foldArguments(mh1, mh2);
137
AssertJUnit.assertEquals(constByte2, (byte) foldMH.invokeExact(constByte1, constByte2, constByte3, Byte.MIN_VALUE));
138
139
/* Verify intermediate condition */
140
combinerMT = methodType(byte.class, byte.class);
141
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
142
foldMH = MethodHandles.foldArguments(mh1, mh2);
143
AssertJUnit.assertEquals(constByte1, (byte) foldMH.invokeExact(constByte1, constByte2, constByte3, constByte4));
144
145
combinerMT = methodType(byte.class, byte.class, byte.class);
146
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
147
foldMH = MethodHandles.foldArguments(mh1, mh2);
148
AssertJUnit.assertEquals(constByte2, (byte) foldMH.invokeExact(constByte1, constByte2, constByte3, constByte4));
149
150
combinerMT = methodType(byte.class, byte.class, byte.class, byte.class);
151
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
152
foldMH = MethodHandles.foldArguments(mh1, mh2);
153
AssertJUnit.assertEquals(constByte2, (byte) foldMH.invokeExact(constByte1, constByte2, constByte3, constByte4));
154
155
combinerMT = methodType(byte.class, byte.class, byte.class, byte.class, byte.class);
156
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByte", combinerMT);
157
foldMH = MethodHandles.foldArguments(mh1, mh2);
158
AssertJUnit.assertEquals(constByte4, (byte) foldMH.invokeExact(constByte1, constByte2, constByte3, constByte4));
159
160
/* void return case */
161
combinerMT = methodType(void.class, byte.class, byte.class, byte.class, byte.class);
162
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerByteVoid", combinerMT);
163
foldMH = MethodHandles.foldArguments(mh1, mh2);
164
AssertJUnit.assertEquals(constByte1, (byte) foldMH.invokeExact(constByte1, constByte2, constByte3, constByte4, Byte.MIN_VALUE));
165
166
/* no paramters case */
167
nextMT = methodType(byte.class);
168
combinerMT = methodType(void.class);
169
mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "minByteNoArgs", nextMT);
170
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerVoidNoArgs", combinerMT);
171
foldMH = MethodHandles.foldArguments(mh1, mh2);
172
AssertJUnit.assertEquals(Byte.MIN_VALUE, (byte) foldMH.invokeExact());
173
}
174
175
public static byte combinerByte () {
176
return Byte.MAX_VALUE;
177
}
178
179
public static byte combinerByte (byte a) {
180
return largestByte (a);
181
}
182
183
public static byte combinerByte (byte a, byte b) {
184
return largestByte (a, b);
185
}
186
187
public static byte combinerByte (byte a, byte b, byte c) {
188
return largestByte (a, b, c);
189
}
190
191
public static byte combinerByte (byte a, byte b, byte c, byte d) {
192
return largestByte (a, b, c, d);
193
}
194
195
public static void combinerByteVoid (byte a, byte b, byte c, byte d) {
196
byte largest = largestByte (a, b, c, d);
197
}
198
199
public static byte nextByte (byte a, byte b, byte c, byte d, byte e) {
200
return a;
201
}
202
203
public static byte largestByte (byte... args) {
204
byte largest = Byte.MIN_VALUE;
205
for(byte arg : args) {
206
if (largest < arg) {
207
largest = arg;
208
}
209
}
210
return largest;
211
}
212
213
public static byte minByteNoArgs() {
214
return Byte.MIN_VALUE;
215
}
216
217
/* Test foldArguments: Combiner's data-type -> short */
218
@Test(groups = { "level.extended" })
219
public void test_foldArguments_Short() throws WrongMethodTypeException, Throwable {
220
MethodType nextMT = methodType(short.class, short.class, short.class, short.class, short.class, short.class);
221
MethodHandle mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "nextShort", nextMT);
222
223
MethodType combinerMT = methodType(short.class);
224
MethodHandle mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
225
226
/* Verify Short.Max_VALUE Boundary Condition */
227
MethodHandle foldMH = MethodHandles.foldArguments(mh1, mh2);
228
AssertJUnit.assertEquals(Short.MAX_VALUE, (short) foldMH.invokeExact(constShort1, constShort2, constShort3, constShort4));
229
230
combinerMT = methodType(short.class, short.class);
231
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
232
foldMH = MethodHandles.foldArguments(mh1, mh2);
233
AssertJUnit.assertEquals(Short.MAX_VALUE, (short) foldMH.invokeExact(Short.MAX_VALUE, constShort2, constShort3, constShort4));
234
235
combinerMT = methodType(short.class, short.class, short.class);
236
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
237
foldMH = MethodHandles.foldArguments(mh1, mh2);
238
AssertJUnit.assertEquals(Short.MAX_VALUE, (short) foldMH.invokeExact(constShort1, Short.MAX_VALUE, constShort3, constShort4));
239
240
combinerMT = methodType(short.class, short.class, short.class, short.class);
241
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
242
foldMH = MethodHandles.foldArguments(mh1, mh2);
243
AssertJUnit.assertEquals(Short.MAX_VALUE, (short) foldMH.invokeExact(constShort1, constShort2, Short.MAX_VALUE, constShort4));
244
245
combinerMT = methodType(short.class, short.class, short.class, short.class, short.class);
246
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
247
foldMH = MethodHandles.foldArguments(mh1, mh2);
248
AssertJUnit.assertEquals(Short.MAX_VALUE, (short) foldMH.invokeExact(constShort1, constShort2, constShort3, Short.MAX_VALUE));
249
250
/* Verify Short.MIN_VALUE boundary condition */
251
combinerMT = methodType(short.class, short.class);
252
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
253
foldMH = MethodHandles.foldArguments(mh1, mh2);
254
AssertJUnit.assertEquals(Short.MIN_VALUE, (short) foldMH.invokeExact(Short.MIN_VALUE, constShort2, constShort3, constShort4));
255
256
combinerMT = methodType(short.class, short.class, short.class);
257
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
258
foldMH = MethodHandles.foldArguments(mh1, mh2);
259
AssertJUnit.assertEquals(constShort1, (short) foldMH.invokeExact(constShort1, Short.MIN_VALUE, constShort3, constShort4));
260
261
combinerMT = methodType(short.class, short.class, short.class, short.class);
262
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
263
foldMH = MethodHandles.foldArguments(mh1, mh2);
264
AssertJUnit.assertEquals(constShort1, (short) foldMH.invokeExact(constShort1, constShort2, Short.MIN_VALUE, constShort4));
265
266
combinerMT = methodType(short.class, short.class, short.class, short.class, short.class);
267
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
268
foldMH = MethodHandles.foldArguments(mh1, mh2);
269
AssertJUnit.assertEquals(constShort3, (short) foldMH.invokeExact(constShort1, constShort2, constShort3, Short.MIN_VALUE));
270
271
/* Verify intermediate condition */
272
combinerMT = methodType(short.class, short.class);
273
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
274
foldMH = MethodHandles.foldArguments(mh1, mh2);
275
AssertJUnit.assertEquals(constShort1, (short) foldMH.invokeExact(constShort1, constShort2, constShort3, constShort4));
276
277
combinerMT = methodType(short.class, short.class, short.class);
278
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
279
foldMH = MethodHandles.foldArguments(mh1, mh2);
280
AssertJUnit.assertEquals(constShort1, (short) foldMH.invokeExact(constShort1, constShort2, constShort3, constShort4));
281
282
combinerMT = methodType(short.class, short.class, short.class, short.class);
283
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
284
foldMH = MethodHandles.foldArguments(mh1, mh2);
285
AssertJUnit.assertEquals(constShort3, (short) foldMH.invokeExact(constShort1, constShort2, constShort3, constShort4));
286
287
combinerMT = methodType(short.class, short.class, short.class, short.class, short.class);
288
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShort", combinerMT);
289
foldMH = MethodHandles.foldArguments(mh1, mh2);
290
AssertJUnit.assertEquals(constShort3, (short) foldMH.invokeExact(constShort1, constShort2, constShort3, constShort4));
291
292
/* void return case */
293
combinerMT = methodType(void.class, short.class, short.class, short.class, short.class);
294
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerShortVoid", combinerMT);
295
foldMH = MethodHandles.foldArguments(mh1, mh2);
296
AssertJUnit.assertEquals(constShort1, (short) foldMH.invokeExact(constShort1, constShort2, constShort3, constShort4, Short.MIN_VALUE));
297
298
/* no paramters case */
299
nextMT = methodType(short.class);
300
combinerMT = methodType(void.class);
301
mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "minShortNoArgs", nextMT);
302
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerVoidNoArgs", combinerMT);
303
foldMH = MethodHandles.foldArguments(mh1, mh2);
304
AssertJUnit.assertEquals(Short.MIN_VALUE, (short) foldMH.invokeExact());
305
}
306
307
public static short combinerShort () {
308
return Short.MAX_VALUE;
309
}
310
311
public static short combinerShort (short a) {
312
return largestShort (a);
313
}
314
315
public static short combinerShort (short a, short b) {
316
return largestShort (a, b);
317
}
318
319
public static short combinerShort (short a, short b, short c) {
320
return largestShort (a, b, c);
321
}
322
323
public static short combinerShort (short a, short b, short c, short d) {
324
return largestShort (a, b, c, d);
325
}
326
327
public static void combinerShortVoid (short a, short b, short c, short d) {
328
short largest = largestShort (a, b, c, d);
329
}
330
331
public static short nextShort (short a, short b, short c, short d, short e) {
332
return a;
333
}
334
335
public static short largestShort (short... args) {
336
short largest = Short.MIN_VALUE;
337
for(short arg : args) {
338
if (largest < arg) {
339
largest = arg;
340
}
341
}
342
return largest;
343
}
344
345
public static short minShortNoArgs() {
346
return Short.MIN_VALUE;
347
}
348
349
/* Test foldArguments: Combiner's data-type -> char */
350
@Test(groups = { "level.extended" })
351
public void test_foldArguments_Character() throws WrongMethodTypeException, Throwable {
352
MethodType nextMT = methodType(char.class, char.class, char.class, char.class, char.class, char.class);
353
MethodHandle mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "nextCharacter", nextMT);
354
355
MethodType combinerMT = methodType(char.class);
356
MethodHandle mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
357
358
/* Verify Character.Max_VALUE Boundary Condition */
359
MethodHandle foldMH = MethodHandles.foldArguments(mh1, mh2);
360
AssertJUnit.assertEquals(Character.MAX_VALUE, (char) foldMH.invokeExact(constCharacter1, constCharacter2, constCharacter3, constCharacter4));
361
362
combinerMT = methodType(char.class, char.class);
363
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
364
foldMH = MethodHandles.foldArguments(mh1, mh2);
365
AssertJUnit.assertEquals(Character.MAX_VALUE, (char) foldMH.invokeExact(Character.MAX_VALUE, constCharacter2, constCharacter3, constCharacter4));
366
367
combinerMT = methodType(char.class, char.class, char.class);
368
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
369
foldMH = MethodHandles.foldArguments(mh1, mh2);
370
AssertJUnit.assertEquals(Character.MAX_VALUE, (char) foldMH.invokeExact(constCharacter1, Character.MAX_VALUE, constCharacter3, constCharacter4));
371
372
combinerMT = methodType(char.class, char.class, char.class, char.class);
373
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
374
foldMH = MethodHandles.foldArguments(mh1, mh2);
375
AssertJUnit.assertEquals(Character.MAX_VALUE, (char) foldMH.invokeExact(constCharacter1, constCharacter2, Character.MAX_VALUE, constCharacter4));
376
377
combinerMT = methodType(char.class, char.class, char.class, char.class, char.class);
378
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
379
foldMH = MethodHandles.foldArguments(mh1, mh2);
380
AssertJUnit.assertEquals(Character.MAX_VALUE, (char) foldMH.invokeExact(constCharacter1, constCharacter2, constCharacter3, Character.MAX_VALUE));
381
382
/* Verify Character.MIN_VALUE boundary condition */
383
combinerMT = methodType(char.class, char.class);
384
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
385
foldMH = MethodHandles.foldArguments(mh1, mh2);
386
AssertJUnit.assertEquals(Character.MIN_VALUE, (char) foldMH.invokeExact(Character.MIN_VALUE, constCharacter2, constCharacter3, constCharacter4));
387
388
combinerMT = methodType(char.class, char.class, char.class);
389
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
390
foldMH = MethodHandles.foldArguments(mh1, mh2);
391
AssertJUnit.assertEquals(constCharacter1, (char) foldMH.invokeExact(constCharacter1, Character.MIN_VALUE, constCharacter3, constCharacter4));
392
393
combinerMT = methodType(char.class, char.class, char.class, char.class);
394
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
395
foldMH = MethodHandles.foldArguments(mh1, mh2);
396
AssertJUnit.assertEquals(constCharacter2, (char) foldMH.invokeExact(constCharacter1, constCharacter2, Character.MIN_VALUE, constCharacter4));
397
398
combinerMT = methodType(char.class, char.class, char.class, char.class, char.class);
399
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
400
foldMH = MethodHandles.foldArguments(mh1, mh2);
401
AssertJUnit.assertEquals(constCharacter3, (char) foldMH.invokeExact(constCharacter1, constCharacter2, constCharacter3, Character.MIN_VALUE));
402
403
/* Verify intermediate condition */
404
combinerMT = methodType(char.class, char.class);
405
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
406
foldMH = MethodHandles.foldArguments(mh1, mh2);
407
AssertJUnit.assertEquals(constCharacter1, (char) foldMH.invokeExact(constCharacter1, constCharacter2, constCharacter3, constCharacter4));
408
409
combinerMT = methodType(char.class, char.class, char.class);
410
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
411
foldMH = MethodHandles.foldArguments(mh1, mh2);
412
AssertJUnit.assertEquals(constCharacter2, (char) foldMH.invokeExact(constCharacter1, constCharacter2, constCharacter3, constCharacter4));
413
414
combinerMT = methodType(char.class, char.class, char.class, char.class);
415
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
416
foldMH = MethodHandles.foldArguments(mh1, mh2);
417
AssertJUnit.assertEquals(constCharacter3, (char) foldMH.invokeExact(constCharacter1, constCharacter2, constCharacter3, constCharacter4));
418
419
combinerMT = methodType(char.class, char.class, char.class, char.class, char.class);
420
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacter", combinerMT);
421
foldMH = MethodHandles.foldArguments(mh1, mh2);
422
AssertJUnit.assertEquals(constCharacter3, (char) foldMH.invokeExact(constCharacter1, constCharacter2, constCharacter3, constCharacter4));
423
424
/* void return case */
425
combinerMT = methodType(void.class, char.class, char.class, char.class, char.class);
426
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerCharacterVoid", combinerMT);
427
foldMH = MethodHandles.foldArguments(mh1, mh2);
428
AssertJUnit.assertEquals(constCharacter1, (char) foldMH.invokeExact(constCharacter1, constCharacter2, constCharacter3, constCharacter4, Character.MIN_VALUE));
429
430
/* no paramters case */
431
nextMT = methodType(char.class);
432
combinerMT = methodType(void.class);
433
mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "minCharNoArgs", nextMT);
434
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerVoidNoArgs", combinerMT);
435
foldMH = MethodHandles.foldArguments(mh1, mh2);
436
AssertJUnit.assertEquals(Character.MIN_VALUE, (char) foldMH.invokeExact());
437
}
438
439
public static char combinerCharacter () {
440
return Character.MAX_VALUE;
441
}
442
443
public static char combinerCharacter (char a) {
444
return largestCharacter (a);
445
}
446
447
public static char combinerCharacter (char a, char b) {
448
return largestCharacter (a, b);
449
}
450
451
public static char combinerCharacter (char a, char b, char c) {
452
return largestCharacter (a, b, c);
453
}
454
455
public static char combinerCharacter (char a, char b, char c, char d) {
456
return largestCharacter (a, b, c, d);
457
}
458
459
public static void combinerCharacterVoid (char a, char b, char c, char d) {
460
char largest = largestCharacter (a, b, c, d);
461
}
462
463
public static char nextCharacter (char a, char b, char c, char d, char e) {
464
return a;
465
}
466
467
public static char largestCharacter (char... args) {
468
char largest = Character.MIN_VALUE;
469
for(char arg : args) {
470
if (largest < arg) {
471
largest = arg;
472
}
473
}
474
return largest;
475
}
476
477
public static char minCharNoArgs() {
478
return Character.MIN_VALUE;
479
}
480
481
/* Test foldArguments: Combiner's data-type -> int */
482
@Test(groups = { "level.extended" })
483
public void test_foldArguments_Integer() throws WrongMethodTypeException, Throwable {
484
MethodType nextMT = methodType(int.class, int.class, int.class, int.class, int.class, int.class);
485
MethodHandle mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "nextInteger", nextMT);
486
487
MethodType combinerMT = methodType(int.class);
488
MethodHandle mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
489
490
/* Verify Integer.Max_VALUE Boundary Condition */
491
MethodHandle foldMH = MethodHandles.foldArguments(mh1, mh2);
492
AssertJUnit.assertEquals(Integer.MAX_VALUE, (int) foldMH.invokeExact(constInteger1, constInteger2, constInteger3, constInteger4));
493
494
combinerMT = methodType(int.class, int.class);
495
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
496
foldMH = MethodHandles.foldArguments(mh1, mh2);
497
AssertJUnit.assertEquals(Integer.MAX_VALUE, (int) foldMH.invokeExact(Integer.MAX_VALUE, constInteger2, constInteger3, constInteger4));
498
499
combinerMT = methodType(int.class, int.class, int.class);
500
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
501
foldMH = MethodHandles.foldArguments(mh1, mh2);
502
AssertJUnit.assertEquals(Integer.MAX_VALUE, (int) foldMH.invokeExact(constInteger1, Integer.MAX_VALUE, constInteger3, constInteger4));
503
504
combinerMT = methodType(int.class, int.class, int.class, int.class);
505
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
506
foldMH = MethodHandles.foldArguments(mh1, mh2);
507
AssertJUnit.assertEquals(Integer.MAX_VALUE, (int) foldMH.invokeExact(constInteger1, constInteger2, Integer.MAX_VALUE, constInteger4));
508
509
combinerMT = methodType(int.class, int.class, int.class, int.class, int.class);
510
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
511
foldMH = MethodHandles.foldArguments(mh1, mh2);
512
AssertJUnit.assertEquals(Integer.MAX_VALUE, (int) foldMH.invokeExact(constInteger1, constInteger2, constInteger3, Integer.MAX_VALUE));
513
514
/* Verify Integer.MIN_VALUE boundary condition */
515
combinerMT = methodType(int.class, int.class);
516
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
517
foldMH = MethodHandles.foldArguments(mh1, mh2);
518
AssertJUnit.assertEquals(Integer.MIN_VALUE, (int) foldMH.invokeExact(Integer.MIN_VALUE, constInteger2, constInteger3, constInteger4));
519
520
combinerMT = methodType(int.class, int.class, int.class);
521
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
522
foldMH = MethodHandles.foldArguments(mh1, mh2);
523
AssertJUnit.assertEquals(constInteger1, (int) foldMH.invokeExact(constInteger1, Integer.MIN_VALUE, constInteger3, constInteger4));
524
525
combinerMT = methodType(int.class, int.class, int.class, int.class);
526
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
527
foldMH = MethodHandles.foldArguments(mh1, mh2);
528
AssertJUnit.assertEquals(constInteger1, (int) foldMH.invokeExact(constInteger1, constInteger2, Integer.MIN_VALUE, constInteger4));
529
530
combinerMT = methodType(int.class, int.class, int.class, int.class, int.class);
531
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
532
foldMH = MethodHandles.foldArguments(mh1, mh2);
533
AssertJUnit.assertEquals(constInteger3, (int) foldMH.invokeExact(constInteger1, constInteger2, constInteger3, Integer.MIN_VALUE));
534
535
/* Verify intermediate condition */
536
combinerMT = methodType(int.class, int.class);
537
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
538
foldMH = MethodHandles.foldArguments(mh1, mh2);
539
AssertJUnit.assertEquals(constInteger1, (int) foldMH.invokeExact(constInteger1, constInteger2, constInteger3, constInteger4));
540
541
combinerMT = methodType(int.class, int.class, int.class);
542
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
543
foldMH = MethodHandles.foldArguments(mh1, mh2);
544
AssertJUnit.assertEquals(constInteger1, (int) foldMH.invokeExact(constInteger1, constInteger2, constInteger3, constInteger4));
545
546
combinerMT = methodType(int.class, int.class, int.class, int.class);
547
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
548
foldMH = MethodHandles.foldArguments(mh1, mh2);
549
AssertJUnit.assertEquals(constInteger3, (int) foldMH.invokeExact(constInteger1, constInteger2, constInteger3, constInteger4));
550
551
combinerMT = methodType(int.class, int.class, int.class, int.class, int.class);
552
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerInteger", combinerMT);
553
foldMH = MethodHandles.foldArguments(mh1, mh2);
554
AssertJUnit.assertEquals(constInteger3, (int) foldMH.invokeExact(constInteger1, constInteger2, constInteger3, constInteger4));
555
556
/* void return case */
557
combinerMT = methodType(void.class, int.class, int.class, int.class, int.class);
558
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerIntegerVoid", combinerMT);
559
foldMH = MethodHandles.foldArguments(mh1, mh2);
560
AssertJUnit.assertEquals(constInteger1, (int) foldMH.invokeExact(constInteger1, constInteger2, constInteger3, constInteger4, Integer.MIN_VALUE));
561
562
/* no paramters case */
563
nextMT = methodType(int.class);
564
combinerMT = methodType(void.class);
565
mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "minIntNoArgs", nextMT);
566
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerVoidNoArgs", combinerMT);
567
foldMH = MethodHandles.foldArguments(mh1, mh2);
568
AssertJUnit.assertEquals(Integer.MIN_VALUE, (int) foldMH.invokeExact());
569
}
570
571
public static int combinerInteger () {
572
return Integer.MAX_VALUE;
573
}
574
575
public static int combinerInteger (int a) {
576
return largestInteger (a);
577
}
578
579
public static int combinerInteger (int a, int b) {
580
return largestInteger (a, b);
581
}
582
583
public static int combinerInteger (int a, int b, int c) {
584
return largestInteger (a, b, c);
585
}
586
587
public static int combinerInteger (int a, int b, int c, int d) {
588
return largestInteger (a, b, c, d);
589
}
590
591
public static void combinerIntegerVoid (int a, int b, int c, int d) {
592
int largest = largestInteger (a, b, c, d);
593
}
594
595
public static int nextInteger (int a, int b, int c, int d, int e) {
596
return a;
597
}
598
599
public static int largestInteger (int... args) {
600
int largest = Integer.MIN_VALUE;
601
for(int arg : args) {
602
if (largest < arg) {
603
largest = arg;
604
}
605
}
606
return largest;
607
}
608
609
public static int minIntNoArgs() {
610
return Integer.MIN_VALUE;
611
}
612
613
/* Test foldArguments: Combiner's data-type -> long */
614
@Test(groups = { "level.extended" })
615
public void test_foldArguments_Long() throws WrongMethodTypeException, Throwable {
616
MethodType nextMT = methodType(long.class, long.class, long.class, long.class, long.class, long.class);
617
MethodHandle mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "nextLong", nextMT);
618
619
MethodType combinerMT = methodType(long.class);
620
MethodHandle mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
621
622
/* Verify Long.Max_VALUE Boundary Condition */
623
MethodHandle foldMH = MethodHandles.foldArguments(mh1, mh2);
624
AssertJUnit.assertEquals(Long.MAX_VALUE, (long) foldMH.invokeExact(constLong1, constLong2, constLong3, constLong4));
625
626
combinerMT = methodType(long.class, long.class);
627
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
628
foldMH = MethodHandles.foldArguments(mh1, mh2);
629
AssertJUnit.assertEquals(Long.MAX_VALUE, (long) foldMH.invokeExact(Long.MAX_VALUE, constLong2, constLong3, constLong4));
630
631
combinerMT = methodType(long.class, long.class, long.class);
632
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
633
foldMH = MethodHandles.foldArguments(mh1, mh2);
634
AssertJUnit.assertEquals(Long.MAX_VALUE, (long) foldMH.invokeExact(constLong1, Long.MAX_VALUE, constLong3, constLong4));
635
636
combinerMT = methodType(long.class, long.class, long.class, long.class);
637
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
638
foldMH = MethodHandles.foldArguments(mh1, mh2);
639
AssertJUnit.assertEquals(Long.MAX_VALUE, (long) foldMH.invokeExact(constLong1, constLong2, Long.MAX_VALUE, constLong4));
640
641
combinerMT = methodType(long.class, long.class, long.class, long.class, long.class);
642
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
643
foldMH = MethodHandles.foldArguments(mh1, mh2);
644
AssertJUnit.assertEquals(Long.MAX_VALUE, (long) foldMH.invokeExact(constLong1, constLong2, constLong3, Long.MAX_VALUE));
645
646
/* Verify Long.MIN_VALUE boundary condition */
647
combinerMT = methodType(long.class, long.class);
648
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
649
foldMH = MethodHandles.foldArguments(mh1, mh2);
650
AssertJUnit.assertEquals(Long.MIN_VALUE, (long) foldMH.invokeExact(Long.MIN_VALUE, constLong2, constLong3, constLong4));
651
652
combinerMT = methodType(long.class, long.class, long.class);
653
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
654
foldMH = MethodHandles.foldArguments(mh1, mh2);
655
AssertJUnit.assertEquals(constLong1, (long) foldMH.invokeExact(constLong1, Long.MIN_VALUE, constLong3, constLong4));
656
657
combinerMT = methodType(long.class, long.class, long.class, long.class);
658
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
659
foldMH = MethodHandles.foldArguments(mh1, mh2);
660
AssertJUnit.assertEquals(constLong2, (long) foldMH.invokeExact(constLong1, constLong2, Long.MIN_VALUE, constLong4));
661
662
combinerMT = methodType(long.class, long.class, long.class, long.class, long.class);
663
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
664
foldMH = MethodHandles.foldArguments(mh1, mh2);
665
AssertJUnit.assertEquals(constLong3, (long) foldMH.invokeExact(constLong1, constLong2, constLong3, Long.MIN_VALUE));
666
667
/* Verify intermediate condition */
668
combinerMT = methodType(long.class, long.class);
669
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
670
foldMH = MethodHandles.foldArguments(mh1, mh2);
671
AssertJUnit.assertEquals(constLong1, (long) foldMH.invokeExact(constLong1, constLong2, constLong3, constLong4));
672
673
combinerMT = methodType(long.class, long.class, long.class);
674
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
675
foldMH = MethodHandles.foldArguments(mh1, mh2);
676
AssertJUnit.assertEquals(constLong2, (long) foldMH.invokeExact(constLong1, constLong2, constLong3, constLong4));
677
678
combinerMT = methodType(long.class, long.class, long.class, long.class);
679
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
680
foldMH = MethodHandles.foldArguments(mh1, mh2);
681
AssertJUnit.assertEquals(constLong3, (long) foldMH.invokeExact(constLong1, constLong2, constLong3, constLong4));
682
683
combinerMT = methodType(long.class, long.class, long.class, long.class, long.class);
684
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLong", combinerMT);
685
foldMH = MethodHandles.foldArguments(mh1, mh2);
686
AssertJUnit.assertEquals(constLong3, (long) foldMH.invokeExact(constLong1, constLong2, constLong3, constLong4));
687
688
/* void return case */
689
combinerMT = methodType(void.class, long.class, long.class, long.class, long.class);
690
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerLongVoid", combinerMT);
691
foldMH = MethodHandles.foldArguments(mh1, mh2);
692
AssertJUnit.assertEquals(constLong1, (long) foldMH.invokeExact(constLong1, constLong2, constLong3, constLong4, Long.MIN_VALUE));
693
694
/* no paramters case */
695
nextMT = methodType(long.class);
696
combinerMT = methodType(void.class);
697
mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "minLongNoArgs", nextMT);
698
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerVoidNoArgs", combinerMT);
699
foldMH = MethodHandles.foldArguments(mh1, mh2);
700
AssertJUnit.assertEquals(Long.MIN_VALUE, (long) foldMH.invokeExact());
701
}
702
703
public static long combinerLong () {
704
return Long.MAX_VALUE;
705
}
706
707
public static long combinerLong (long a) {
708
return largestLong (a);
709
}
710
711
public static long combinerLong (long a, long b) {
712
return largestLong (a, b);
713
}
714
715
public static long combinerLong (long a, long b, long c) {
716
return largestLong (a, b, c);
717
}
718
719
public static long combinerLong (long a, long b, long c, long d) {
720
return largestLong (a, b, c, d);
721
}
722
723
public static void combinerLongVoid (long a, long b, long c, long d) {
724
long largest = largestLong (a, b, c, d);
725
}
726
727
public static long nextLong (long a, long b, long c, long d, long e) {
728
return a;
729
}
730
731
public static long largestLong (long... args) {
732
long largest = Long.MIN_VALUE;
733
for(long arg : args) {
734
if (largest < arg) {
735
largest = arg;
736
}
737
}
738
return largest;
739
}
740
741
public static long minLongNoArgs() {
742
return Long.MIN_VALUE;
743
}
744
745
/* Test foldArguments: Combiner's data-type -> float */
746
@Test(groups = { "level.extended" })
747
public void test_foldArguments_Float() throws WrongMethodTypeException, Throwable {
748
MethodType nextMT = methodType(float.class, float.class, float.class, float.class, float.class, float.class);
749
MethodHandle mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "nextFloat", nextMT);
750
751
MethodType combinerMT = methodType(float.class);
752
MethodHandle mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
753
754
/* Verify Float.Max_VALUE Boundary Condition */
755
MethodHandle foldMH = MethodHandles.foldArguments(mh1, mh2);
756
AssertJUnit.assertEquals(Float.MAX_VALUE, (float) foldMH.invokeExact(constFloat1, constFloat2, constFloat3, constFloat4));
757
758
combinerMT = methodType(float.class, float.class);
759
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
760
foldMH = MethodHandles.foldArguments(mh1, mh2);
761
AssertJUnit.assertEquals(Float.MAX_VALUE, (float) foldMH.invokeExact(Float.MAX_VALUE, constFloat2, constFloat3, constFloat4));
762
763
combinerMT = methodType(float.class, float.class, float.class);
764
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
765
foldMH = MethodHandles.foldArguments(mh1, mh2);
766
AssertJUnit.assertEquals(Float.MAX_VALUE, (float) foldMH.invokeExact(constFloat1, Float.MAX_VALUE, constFloat3, constFloat4));
767
768
combinerMT = methodType(float.class, float.class, float.class, float.class);
769
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
770
foldMH = MethodHandles.foldArguments(mh1, mh2);
771
AssertJUnit.assertEquals(Float.MAX_VALUE, (float) foldMH.invokeExact(constFloat1, constFloat2, Float.MAX_VALUE, constFloat4));
772
773
combinerMT = methodType(float.class, float.class, float.class, float.class, float.class);
774
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
775
foldMH = MethodHandles.foldArguments(mh1, mh2);
776
AssertJUnit.assertEquals(Float.MAX_VALUE, (float) foldMH.invokeExact(constFloat1, constFloat2, constFloat3, Float.MAX_VALUE));
777
778
/* Verify Float.MIN_VALUE boundary condition */
779
combinerMT = methodType(float.class, float.class);
780
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
781
foldMH = MethodHandles.foldArguments(mh1, mh2);
782
AssertJUnit.assertEquals(Float.MIN_VALUE, (float) foldMH.invokeExact(Float.MIN_VALUE, constFloat2, constFloat3, constFloat4));
783
784
combinerMT = methodType(float.class, float.class, float.class);
785
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
786
foldMH = MethodHandles.foldArguments(mh1, mh2);
787
AssertJUnit.assertEquals(constFloat1, (float) foldMH.invokeExact(constFloat1, Float.MIN_VALUE, constFloat3, constFloat4));
788
789
combinerMT = methodType(float.class, float.class, float.class, float.class);
790
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
791
foldMH = MethodHandles.foldArguments(mh1, mh2);
792
AssertJUnit.assertEquals(constFloat1, (float) foldMH.invokeExact(constFloat1, constFloat2, Float.MIN_VALUE, constFloat4));
793
794
combinerMT = methodType(float.class, float.class, float.class, float.class, float.class);
795
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
796
foldMH = MethodHandles.foldArguments(mh1, mh2);
797
AssertJUnit.assertEquals(constFloat1, (float) foldMH.invokeExact(constFloat1, constFloat2, constFloat3, Float.MIN_VALUE));
798
799
/* Verify intermediate condition */
800
combinerMT = methodType(float.class, float.class);
801
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
802
foldMH = MethodHandles.foldArguments(mh1, mh2);
803
AssertJUnit.assertEquals(constFloat1, (float) foldMH.invokeExact(constFloat1, constFloat2, constFloat3, constFloat4));
804
805
combinerMT = methodType(float.class, float.class, float.class);
806
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
807
foldMH = MethodHandles.foldArguments(mh1, mh2);
808
AssertJUnit.assertEquals(constFloat1, (float) foldMH.invokeExact(constFloat1, constFloat2, constFloat3, constFloat4));
809
810
combinerMT = methodType(float.class, float.class, float.class, float.class);
811
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
812
foldMH = MethodHandles.foldArguments(mh1, mh2);
813
AssertJUnit.assertEquals(constFloat1, (float) foldMH.invokeExact(constFloat1, constFloat2, constFloat3, constFloat4));
814
815
combinerMT = methodType(float.class, float.class, float.class, float.class, float.class);
816
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloat", combinerMT);
817
foldMH = MethodHandles.foldArguments(mh1, mh2);
818
AssertJUnit.assertEquals(constFloat1, (float) foldMH.invokeExact(constFloat1, constFloat2, constFloat3, constFloat4));
819
820
/* void return case */
821
combinerMT = methodType(void.class, float.class, float.class, float.class, float.class);
822
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerFloatVoid", combinerMT);
823
foldMH = MethodHandles.foldArguments(mh1, mh2);
824
AssertJUnit.assertEquals(constFloat1, (float) foldMH.invokeExact(constFloat1, constFloat2, constFloat3, constFloat4, Float.MIN_VALUE));
825
826
/* no paramters case */
827
nextMT = methodType(float.class);
828
combinerMT = methodType(void.class);
829
mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "minFloatNoArgs", nextMT);
830
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerVoidNoArgs", combinerMT);
831
foldMH = MethodHandles.foldArguments(mh1, mh2);
832
AssertJUnit.assertEquals(Float.MIN_VALUE, (float) foldMH.invokeExact());
833
}
834
835
public static float combinerFloat () {
836
return Float.MAX_VALUE;
837
}
838
839
public static float combinerFloat (float a) {
840
return largestFloat (a);
841
}
842
843
public static float combinerFloat (float a, float b) {
844
return largestFloat (a, b);
845
}
846
847
public static float combinerFloat (float a, float b, float c) {
848
return largestFloat (a, b, c);
849
}
850
851
public static float combinerFloat (float a, float b, float c, float d) {
852
return largestFloat (a, b, c, d);
853
}
854
855
public static void combinerFloatVoid (float a, float b, float c, float d) {
856
float largest = largestFloat (a, b, c, d);
857
}
858
859
public static float nextFloat (float a, float b, float c, float d, float e) {
860
return a;
861
}
862
863
public static float largestFloat (float... args) {
864
float largest = Float.MIN_VALUE;
865
for(float arg : args) {
866
if (largest < arg) {
867
largest = arg;
868
}
869
}
870
return largest;
871
}
872
873
public static float minFloatNoArgs() {
874
return Float.MIN_VALUE;
875
}
876
877
/* Test foldArguments: Combiner's data-type -> double */
878
@Test(groups = { "level.extended" })
879
public void test_foldArguments_Double() throws WrongMethodTypeException, Throwable {
880
MethodType nextMT = methodType(double.class, double.class, double.class, double.class, double.class, double.class);
881
MethodHandle mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "nextDouble", nextMT);
882
883
MethodType combinerMT = methodType(double.class);
884
MethodHandle mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
885
886
/* Verify Double.Max_VALUE Boundary Condition */
887
MethodHandle foldMH = MethodHandles.foldArguments(mh1, mh2);
888
AssertJUnit.assertEquals(Double.MAX_VALUE, (double) foldMH.invokeExact(constDouble1, constDouble2, constDouble3, constDouble4));
889
890
combinerMT = methodType(double.class, double.class);
891
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
892
foldMH = MethodHandles.foldArguments(mh1, mh2);
893
AssertJUnit.assertEquals(Double.MAX_VALUE, (double) foldMH.invokeExact(Double.MAX_VALUE, constDouble2, constDouble3, constDouble4));
894
895
combinerMT = methodType(double.class, double.class, double.class);
896
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
897
foldMH = MethodHandles.foldArguments(mh1, mh2);
898
AssertJUnit.assertEquals(Double.MAX_VALUE, (double) foldMH.invokeExact(constDouble1, Double.MAX_VALUE, constDouble3, constDouble4));
899
900
combinerMT = methodType(double.class, double.class, double.class, double.class);
901
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
902
foldMH = MethodHandles.foldArguments(mh1, mh2);
903
AssertJUnit.assertEquals(Double.MAX_VALUE, (double) foldMH.invokeExact(constDouble1, constDouble2, Double.MAX_VALUE, constDouble4));
904
905
combinerMT = methodType(double.class, double.class, double.class, double.class, double.class);
906
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
907
foldMH = MethodHandles.foldArguments(mh1, mh2);
908
AssertJUnit.assertEquals(Double.MAX_VALUE, (double) foldMH.invokeExact(constDouble1, constDouble2, constDouble3, Double.MAX_VALUE));
909
910
/* Verify Double.MIN_VALUE boundary condition */
911
combinerMT = methodType(double.class, double.class);
912
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
913
foldMH = MethodHandles.foldArguments(mh1, mh2);
914
AssertJUnit.assertEquals(Double.MIN_VALUE, (double) foldMH.invokeExact(Double.MIN_VALUE, constDouble2, constDouble3, constDouble4));
915
916
combinerMT = methodType(double.class, double.class, double.class);
917
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
918
foldMH = MethodHandles.foldArguments(mh1, mh2);
919
AssertJUnit.assertEquals(constDouble1, (double) foldMH.invokeExact(constDouble1, Double.MIN_VALUE, constDouble3, constDouble4));
920
921
combinerMT = methodType(double.class, double.class, double.class, double.class);
922
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
923
foldMH = MethodHandles.foldArguments(mh1, mh2);
924
AssertJUnit.assertEquals(constDouble2, (double) foldMH.invokeExact(constDouble1, constDouble2, Double.MIN_VALUE, constDouble4));
925
926
combinerMT = methodType(double.class, double.class, double.class, double.class, double.class);
927
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
928
foldMH = MethodHandles.foldArguments(mh1, mh2);
929
AssertJUnit.assertEquals(constDouble3, (double) foldMH.invokeExact(constDouble1, constDouble2, constDouble3, Double.MIN_VALUE));
930
931
/* Verify intermediate condition */
932
combinerMT = methodType(double.class, double.class);
933
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
934
foldMH = MethodHandles.foldArguments(mh1, mh2);
935
AssertJUnit.assertEquals(constDouble1, (double) foldMH.invokeExact(constDouble1, constDouble2, constDouble3, constDouble4));
936
937
combinerMT = methodType(double.class, double.class, double.class);
938
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
939
foldMH = MethodHandles.foldArguments(mh1, mh2);
940
AssertJUnit.assertEquals(constDouble2, (double) foldMH.invokeExact(constDouble1, constDouble2, constDouble3, constDouble4));
941
942
combinerMT = methodType(double.class, double.class, double.class, double.class);
943
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
944
foldMH = MethodHandles.foldArguments(mh1, mh2);
945
AssertJUnit.assertEquals(constDouble3, (double) foldMH.invokeExact(constDouble1, constDouble2, constDouble3, constDouble4));
946
947
combinerMT = methodType(double.class, double.class, double.class, double.class, double.class);
948
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDouble", combinerMT);
949
foldMH = MethodHandles.foldArguments(mh1, mh2);
950
AssertJUnit.assertEquals(constDouble4, (double) foldMH.invokeExact(constDouble1, constDouble2, constDouble3, constDouble4));
951
952
/* void return case */
953
combinerMT = methodType(void.class, double.class, double.class, double.class, double.class);
954
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleVoid", combinerMT);
955
foldMH = MethodHandles.foldArguments(mh1, mh2);
956
AssertJUnit.assertEquals(constDouble1, (double) foldMH.invokeExact(constDouble1, constDouble2, constDouble3, constDouble4, Double.MIN_VALUE));
957
958
/* no paramters case */
959
nextMT = methodType(double.class);
960
combinerMT = methodType(void.class);
961
mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "minDoubleNoArgs", nextMT);
962
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerVoidNoArgs", combinerMT);
963
foldMH = MethodHandles.foldArguments(mh1, mh2);
964
AssertJUnit.assertEquals(Double.MIN_VALUE, (double) foldMH.invokeExact());
965
}
966
967
public static double combinerDouble () {
968
return Double.MAX_VALUE;
969
}
970
971
public static double combinerDouble (double a) {
972
return largestDouble (a);
973
}
974
975
public static double combinerDouble (double a, double b) {
976
return largestDouble (a, b);
977
}
978
979
public static double combinerDouble (double a, double b, double c) {
980
return largestDouble (a, b, c);
981
}
982
983
public static double combinerDouble (double a, double b, double c, double d) {
984
return largestDouble (a, b, c, d);
985
}
986
987
public static void combinerDoubleVoid (double a, double b, double c, double d) {
988
double largest = largestDouble (a, b, c, d);
989
}
990
991
public static double nextDouble (double a, double b, double c, double d, double e) {
992
return a;
993
}
994
995
public static double largestDouble (double... args) {
996
double largest = Double.MIN_VALUE;
997
for(double arg : args) {
998
if (largest < arg) {
999
largest = arg;
1000
}
1001
}
1002
return largest;
1003
}
1004
1005
public static double minDoubleNoArgs() {
1006
return Double.MIN_VALUE;
1007
}
1008
1009
/* Test foldArguments: Combiner's data-type -> Double (Object) */
1010
@Test(groups = { "level.extended" })
1011
public void test_foldArguments_DoubleObject() throws WrongMethodTypeException, Throwable {
1012
MethodType nextMT = methodType(Double.class, Double.class, Double.class, Double.class, Double.class, Double.class);
1013
MethodHandle mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "nextDoubleObject", nextMT);
1014
1015
MethodType combinerMT = methodType(Double.class);
1016
MethodHandle mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1017
1018
Double d1 = new Double (constDouble1);
1019
Double d2 = new Double (constDouble2);
1020
Double d3 = new Double (constDouble3);
1021
Double d4 = new Double (constDouble4);
1022
Double dMax = new Double (Double.MAX_VALUE);
1023
Double dMin = new Double (Double.MIN_VALUE);
1024
1025
/* Verify Double.Max_VALUE Boundary Condition */
1026
MethodHandle foldMH = MethodHandles.foldArguments(mh1, mh2);
1027
AssertJUnit.assertEquals(dMax, (Double) foldMH.invokeExact(d1, d2, d3, d4));
1028
1029
combinerMT = methodType(Double.class, Double.class);
1030
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1031
foldMH = MethodHandles.foldArguments(mh1, mh2);
1032
AssertJUnit.assertEquals(dMax, (Double) foldMH.invokeExact(dMax, d2, d3, d4));
1033
1034
combinerMT = methodType(Double.class, Double.class, Double.class);
1035
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1036
foldMH = MethodHandles.foldArguments(mh1, mh2);
1037
AssertJUnit.assertEquals(dMax, (Double) foldMH.invokeExact(d1, dMax, d3, d4));
1038
1039
combinerMT = methodType(Double.class, Double.class, Double.class, Double.class);
1040
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1041
foldMH = MethodHandles.foldArguments(mh1, mh2);
1042
AssertJUnit.assertEquals(dMax, (Double) foldMH.invokeExact(d1, d2, dMax, d4));
1043
1044
combinerMT = methodType(Double.class, Double.class, Double.class, Double.class, Double.class);
1045
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1046
foldMH = MethodHandles.foldArguments(mh1, mh2);
1047
AssertJUnit.assertEquals(dMax, (Double) foldMH.invokeExact(d1, d2, d3, dMax));
1048
1049
/* Verify dMin boundary condition */
1050
combinerMT = methodType(Double.class, Double.class);
1051
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1052
foldMH = MethodHandles.foldArguments(mh1, mh2);
1053
AssertJUnit.assertEquals(dMin, (Double) foldMH.invokeExact(dMin, d2, d3, d4));
1054
1055
combinerMT = methodType(Double.class, Double.class, Double.class);
1056
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1057
foldMH = MethodHandles.foldArguments(mh1, mh2);
1058
AssertJUnit.assertEquals(d1, (Double) foldMH.invokeExact(d1, dMin, d3, d4));
1059
1060
combinerMT = methodType(Double.class, Double.class, Double.class, Double.class);
1061
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1062
foldMH = MethodHandles.foldArguments(mh1, mh2);
1063
AssertJUnit.assertEquals(d2, (Double) foldMH.invokeExact(d1, d2, dMin, d4));
1064
1065
combinerMT = methodType(Double.class, Double.class, Double.class, Double.class, Double.class);
1066
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1067
foldMH = MethodHandles.foldArguments(mh1, mh2);
1068
AssertJUnit.assertEquals(d3, (Double) foldMH.invokeExact(d1, d2, d3, dMin));
1069
1070
/* Verify intermediate condition */
1071
combinerMT = methodType(Double.class, Double.class);
1072
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1073
foldMH = MethodHandles.foldArguments(mh1, mh2);
1074
AssertJUnit.assertEquals(d1, (Double) foldMH.invokeExact(d1, d2, d3, d4));
1075
1076
combinerMT = methodType(Double.class, Double.class, Double.class);
1077
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1078
foldMH = MethodHandles.foldArguments(mh1, mh2);
1079
AssertJUnit.assertEquals(d2, (Double) foldMH.invokeExact(d1, d2, d3, d4));
1080
1081
combinerMT = methodType(Double.class, Double.class, Double.class, Double.class);
1082
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1083
foldMH = MethodHandles.foldArguments(mh1, mh2);
1084
AssertJUnit.assertEquals(d3, (Double) foldMH.invokeExact(d1, d2, d3, d4));
1085
1086
combinerMT = methodType(Double.class, Double.class, Double.class, Double.class, Double.class);
1087
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObject", combinerMT);
1088
foldMH = MethodHandles.foldArguments(mh1, mh2);
1089
AssertJUnit.assertEquals(d4, (Double) foldMH.invokeExact(d1, d2, d3, d4));
1090
1091
/* void return case */
1092
combinerMT = methodType(void.class, Double.class, Double.class, Double.class, Double.class);
1093
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerDoubleObjectVoid", combinerMT);
1094
foldMH = MethodHandles.foldArguments(mh1, mh2);
1095
AssertJUnit.assertEquals(d1, (Double) foldMH.invokeExact(d1, d2, d3, d4, dMin));
1096
1097
/* no paramters case */
1098
nextMT = methodType(Double.class);
1099
combinerMT = methodType(void.class);
1100
mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "minDoubleObjNoArgs", nextMT);
1101
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerVoidNoArgs", combinerMT);
1102
foldMH = MethodHandles.foldArguments(mh1, mh2);
1103
AssertJUnit.assertEquals(dMin, (Double) foldMH.invokeExact());
1104
}
1105
1106
public static Double combinerDoubleObject () {
1107
Double ret = new Double (Double.MAX_VALUE);
1108
return ret;
1109
}
1110
1111
public static Double combinerDoubleObject (Double a) {
1112
return largestDoubleObject (a);
1113
}
1114
1115
public static Double combinerDoubleObject (Double a, Double b) {
1116
return largestDoubleObject (a, b);
1117
}
1118
1119
public static Double combinerDoubleObject (Double a, Double b, Double c) {
1120
return largestDoubleObject (a, b, c);
1121
}
1122
1123
public static Double combinerDoubleObject (Double a, Double b, Double c, Double d) {
1124
return largestDoubleObject (a, b, c, d);
1125
}
1126
1127
public static void combinerDoubleObjectVoid (Double a, Double b, Double c, Double d) {
1128
Double largest = largestDoubleObject (a, b, c, d);
1129
}
1130
1131
public static Double nextDoubleObject (Double a, Double b, Double c, Double d, Double e) {
1132
return a;
1133
}
1134
1135
public static Double largestDoubleObject (Double... args) {
1136
Double largest = Double.MIN_VALUE;
1137
for(Double arg : args) {
1138
if (largest.doubleValue() < arg.doubleValue()) {
1139
largest = arg;
1140
}
1141
}
1142
return largest;
1143
}
1144
1145
public static Double minDoubleObjNoArgs() {
1146
Double ret = new Double (Double.MIN_VALUE);
1147
return ret;
1148
}
1149
1150
/* Test foldArguments: Combiner's data-type -> boolean */
1151
@Test(groups = { "level.extended" })
1152
public void test_foldArguments_Boolean() throws WrongMethodTypeException, Throwable {
1153
MethodType nextMT = methodType(boolean.class, boolean.class, boolean.class, boolean.class);
1154
MethodHandle mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "nextBoolean", nextMT);
1155
1156
MethodType combinerMT = methodType(boolean.class);
1157
MethodHandle mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerBoolean", combinerMT);
1158
1159
MethodHandle foldMH = MethodHandles.foldArguments(mh1, mh2);
1160
AssertJUnit.assertEquals(constBoolMax, (boolean) foldMH.invokeExact(constBoolMax, constBoolMin));
1161
1162
combinerMT = methodType(boolean.class, boolean.class);
1163
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerBoolean", combinerMT);
1164
foldMH = MethodHandles.foldArguments(mh1, mh2);
1165
AssertJUnit.assertEquals(constBoolMax, (boolean) foldMH.invokeExact(constBoolMax, constBoolMin));
1166
1167
combinerMT = methodType(boolean.class, boolean.class, boolean.class);
1168
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerBoolean", combinerMT);
1169
foldMH = MethodHandles.foldArguments(mh1, mh2);
1170
AssertJUnit.assertEquals(constBoolMin, (boolean) foldMH.invokeExact(constBoolMax, constBoolMin));
1171
1172
/* void return case */
1173
combinerMT = methodType(void.class, boolean.class, boolean.class);
1174
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerBooleanVoid", combinerMT);
1175
foldMH = MethodHandles.foldArguments(mh1, mh2);
1176
AssertJUnit.assertEquals(constBoolMin, (boolean) foldMH.invokeExact(constBoolMin, constBoolMax, constBoolMin));
1177
1178
/* no paramters case */
1179
nextMT = methodType(boolean.class);
1180
combinerMT = methodType(void.class);
1181
mh1 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "minBooleanNoArgs", nextMT);
1182
mh2 = MethodHandles.publicLookup().findStatic(FoldArgumentsTest.class, "combinerVoidNoArgs", combinerMT);
1183
foldMH = MethodHandles.foldArguments(mh1, mh2);
1184
AssertJUnit.assertEquals(constBoolMin, (boolean) foldMH.invokeExact());
1185
}
1186
1187
public static boolean combinerBoolean () {
1188
return constBoolMax;
1189
}
1190
1191
public static boolean combinerBoolean (boolean a) {
1192
return lastBoolean (a);
1193
}
1194
1195
public static boolean combinerBoolean (boolean a, boolean b) {
1196
return lastBoolean (a, b);
1197
}
1198
1199
public static void combinerBooleanVoid (boolean a, boolean b) {
1200
boolean last = lastBoolean (a, b);
1201
}
1202
1203
public static boolean nextBoolean (boolean a, boolean b, boolean c) {
1204
return a;
1205
}
1206
1207
public static boolean lastBoolean (boolean... args) {
1208
boolean last = constBoolMin;
1209
for(boolean arg: args) {
1210
last = arg;
1211
}
1212
return last;
1213
}
1214
1215
public static boolean minBooleanNoArgs() {
1216
return constBoolMin;
1217
}
1218
1219
/* if target MH takes no args, then return type of combiner needs to be void */
1220
public static void combinerVoidNoArgs() {}
1221
}
1222
1223