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/MethodHandleTest.java
6007 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 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.Assert;
26
import java.lang.invoke.MethodHandle;
27
import java.lang.invoke.MethodHandles;
28
import java.lang.invoke.MethodType;
29
import java.lang.invoke.WrongMethodTypeException;
30
import java.util.ArrayList;
31
import java.util.Arrays;
32
import java.util.List;
33
import java.util.NavigableMap;
34
import java.util.TreeMap;
35
import examples.PackageExamples;
36
37
/**
38
* @author mesbah
39
* This class contains tests for the MethodType API.
40
*/
41
public class MethodHandleTest{
42
43
/****************************
44
* Tests for asCollector
45
* **************************/
46
47
/**
48
* Basic asCollector test. Tests by invoking a MH obtained through a findVirtual call to a class in the same package
49
* @throws Throwable
50
*/
51
@Test(groups = { "level.extended" })
52
public void test_asCollector_SamePackage_Virtual() throws Throwable{
53
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class, String[].class));
54
SamePackageExample g = new SamePackageExample();
55
mh = mh.bindTo(g);
56
mh = mh.asCollector(String[].class, 5);
57
58
Assert.assertEquals(mh.type(), MethodType.methodType(String.class,String.class,String.class,String.class,String.class,String.class));
59
Assert.assertEquals((String)mh.invokeExact("A","star","I am looking at","may already have","died"), "[A,star,I am looking at,may already have,died]");
60
}
61
62
/**
63
* Basic asCollector test. Tests by invoking a MH obtained through a findStatic call to a class in the same package
64
* @throws Throwable
65
*/
66
@Test(groups = { "level.extended" })
67
public void test_asCollector_SamePackage_Static() throws Throwable{
68
MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class,"getLengthStatic",MethodType.methodType(int.class, String[].class));
69
mh = mh.asCollector(String[].class, 5);
70
71
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,String.class,String.class,String.class,String.class,String.class));
72
Assert.assertEquals((int)mh.invokeExact("A","star","I am looking at","may already have","died"), 5);
73
}
74
75
/**
76
* asCollector test using Arrays.deepToString
77
* @throws Throwable
78
*/
79
@Test(groups = { "level.extended" })
80
public void test_asCollector_SamePackage_Static_Array() throws Throwable{
81
MethodHandle mh = MethodHandles.lookup().findStatic(Arrays.class,"deepToString",MethodType.methodType(String.class, Object[].class));
82
mh = mh.asCollector(Object[].class, 1);
83
84
Assert.assertEquals((String)mh.invokeExact( (Object) new Object[] {"There", "is", "nothing", "outside of text"}), "[[There, is, nothing, outside of text]]");
85
}
86
87
/**
88
* Negative test : asCollector using wrong type on a MH obtained through a findVirtual call to a class in the same package
89
* @throws Throwable
90
*/
91
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
92
public void test_asCollector_SamePackage_Virtual_WrongType() throws Throwable{
93
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class, String[].class));
94
SamePackageExample g = new SamePackageExample();
95
mh = mh.bindTo(g);
96
mh = mh.asCollector(int[].class, 2);
97
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong method type");
98
}
99
100
/**
101
* Cross package test : asCollector MH for a virtual method of a class in a different package
102
* @throws Throwable
103
*/
104
@Test(groups = { "level.extended" })
105
public void test_asCollector_CrossPackage_Virtual() throws Throwable{
106
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"getLength",MethodType.methodType(int.class, String[].class));
107
PackageExamples g = new PackageExamples();
108
mh = mh.bindTo(g);
109
mh = mh.asCollector(String[].class, 5);
110
111
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,String.class,String.class,String.class,String.class,String.class));
112
Assert.assertEquals((int)mh.invokeExact("A","star","I am looking at","may already have","died"), 5);
113
}
114
115
/**
116
* Cross package test : asCollector MH for a static method of a class in a different package
117
* @throws Throwable
118
*/
119
@Test(groups = { "level.extended" })
120
public void test_asCollector_CrossPackage_Static() throws Throwable{
121
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"getLengthStatic",MethodType.methodType(int.class, String[].class));
122
mh = mh.asCollector(String[].class, 5);
123
124
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,String.class,String.class,String.class,String.class,String.class));
125
Assert.assertEquals((int)mh.invokeExact("A","star","I am looking at","may already have","died"), 5);
126
}
127
128
/**
129
* Negative test : asCollector using wrong type on a MH obtained through a findVirtual call to a class in a different package
130
* @throws Throwable
131
*/
132
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
133
public void test_asCollector_CrossPackage_Virtual_WrongType() throws Throwable{
134
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"getLength",MethodType.methodType(int.class, String[].class));
135
PackageExamples g = new PackageExamples();
136
mh = mh.bindTo(g);
137
mh = mh.asCollector(int[].class, 2);
138
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong method type");
139
}
140
141
/**
142
* Negative test : asCollector using wrong type on a MH that has no array argument , obtained through a findVirtual call to a class in a different package
143
* @throws Throwable
144
*/
145
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
146
public void test_asCollector_CrossPackage_Virtual_WrongType_nonArrayTarget() throws Throwable{
147
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"addPublic",MethodType.methodType(int.class, int.class, int.class));
148
PackageExamples g = new PackageExamples();
149
mh = mh.bindTo(g);
150
mh = mh.asCollector(int[].class, 2);
151
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong method type");
152
}
153
154
/**
155
* asCollector test for compatible array types - ie: MH takes Object[], asCollector it to String[]
156
* @throws Throwable
157
*/
158
@Test(groups = { "level.extended" })
159
public void test_asCollector_CompatibleArrayTypes_StringToObject() throws Throwable {
160
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class,Object[].class));
161
SamePackageExample g = new SamePackageExample();
162
mh = mh.bindTo(g);
163
mh = mh.asCollector(String[].class, 2);
164
Assert.assertEquals((String)mh.invokeExact("a","b"), "[a,b]");
165
}
166
167
/**
168
* asCollector test for the special case of a MH with Object as the final arg - asCollector that to an array
169
* @throws Throwable
170
*/
171
@Test(groups = { "level.extended" })
172
public void test_asCollector_TypeCompatibility_Array_Object() throws Throwable {
173
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"toOjectArrayString",MethodType.methodType(String.class,Object.class));
174
SamePackageExample g = new SamePackageExample();
175
mh = mh.bindTo(g);
176
mh = mh.asCollector(Object[].class, 6);
177
Assert.assertEquals(mh.invoke("a",1000,true,1.1,Long.MAX_VALUE,Short.MIN_VALUE), "[a,1000,true,1.1,9223372036854775807,-32768]");
178
}
179
180
/**
181
* asCollector test for the corner cases: 0 sized array, different array types when using 0, etc
182
* @throws Throwable
183
*/
184
@Test(groups = { "level.extended" })
185
public void test_asCollector_ZeroSizedArray() throws Throwable{
186
//test with String array
187
MethodHandle mhGetLength = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class,String[].class));
188
SamePackageExample g = new SamePackageExample();
189
mhGetLength = mhGetLength.bindTo(g);
190
mhGetLength = mhGetLength.asCollector(String[].class, 0);
191
Assert.assertEquals((int)mhGetLength.invokeExact(), 0);
192
193
//test with Object array
194
MethodHandle mhArrayToString = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class,Object[].class));
195
mhArrayToString = mhArrayToString.bindTo(g);
196
mhArrayToString = mhArrayToString.asCollector(String[].class,0);
197
Assert.assertEquals((String)mhArrayToString.invokeExact(), "[]");
198
199
//test with byte array
200
MethodHandle mhByteArray = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class,byte[].class));
201
mhByteArray = mhByteArray.bindTo(g);
202
mhByteArray = mhByteArray.asCollector(byte[].class,0);
203
Assert.assertEquals((int)mhByteArray.invokeExact(), 0);
204
205
//test with short array
206
MethodHandle mhShortArray = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class,short[].class));
207
mhShortArray = mhShortArray.bindTo(g);
208
mhShortArray = mhShortArray.asCollector(short[].class,0);
209
Assert.assertEquals((int)mhShortArray.invokeExact(), 0);
210
211
//test with boolean array
212
MethodHandle mhBooleanArray = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class,boolean[].class));
213
mhBooleanArray = mhBooleanArray.bindTo(g);
214
mhBooleanArray = mhBooleanArray.asCollector(boolean[].class,0);
215
Assert.assertEquals((int)mhBooleanArray.invokeExact(), 0);
216
217
//test with long array
218
MethodHandle mhLongArray = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class,long[].class));
219
mhLongArray = mhLongArray.bindTo(g);
220
mhLongArray = mhLongArray.asCollector(long[].class,0);
221
Assert.assertEquals((int)mhLongArray.invokeExact(), 0);
222
223
//test with char array
224
MethodHandle mhCharArray = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class,char[].class));
225
mhCharArray = mhCharArray.bindTo(g);
226
mhCharArray = mhCharArray.asCollector(char[].class,0);
227
Assert.assertEquals((int)mhCharArray.invokeExact(), 0);
228
229
//test with double array
230
MethodHandle mhDoubleArray = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class,double[].class));
231
mhDoubleArray = mhDoubleArray.bindTo(g);
232
mhDoubleArray = mhDoubleArray.asCollector(double[].class,0);
233
Assert.assertEquals((int)mhDoubleArray.invokeExact(), 0);
234
235
//test with float array
236
MethodHandle mhFloatArray = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class,float[].class));
237
mhFloatArray = mhFloatArray.bindTo(g);
238
mhFloatArray = mhFloatArray.asCollector(float[].class,0);
239
Assert.assertEquals((int)mhFloatArray.invokeExact(), 0);
240
241
//test with int array
242
MethodHandle mhIntArray = MethodHandles.lookup().findVirtual(SamePackageExample.class,"getLength",MethodType.methodType(int.class,int[].class));
243
mhIntArray = mhIntArray.bindTo(g);
244
mhIntArray = mhIntArray.asCollector(int[].class,0);
245
Assert.assertEquals((int)mhIntArray.invokeExact(), 0);
246
}
247
248
249
/******************************
250
* Tests for asVarargsCollector
251
* ****************************/
252
253
/**
254
* Basic asVarargsCollector test using a virtual method in a class living in the same package (uses MethodHandle.invoke)
255
* @throws Throwable
256
*/
257
@Test(groups = { "level.extended" })
258
public void test_asVarargsCollector_SamePackage_Virtual_Invoke() throws Throwable {
259
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class, String[].class));
260
SamePackageExample g = new SamePackageExample();
261
mh = mh.bindTo(g);
262
mh = mh.asVarargsCollector(String[].class);
263
264
Assert.assertEquals(mh.type(), MethodType.methodType(String.class,String[].class));
265
Assert.assertEquals(mh.invoke("A","star","I am looking at","may already have","died"), "[A,star,I am looking at,may already have,died]");
266
}
267
268
/**
269
* Basic asVarargsCollector test using a virtual method in a class living in the same package (uses MethodHandle.invokeExact)
270
* @throws Throwable
271
*/
272
@Test(groups = { "level.extended" })
273
public void test_asVarargsCollector_SamePackage_Virtual_InvokeExact() throws Throwable {
274
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class, String[].class));
275
SamePackageExample g = new SamePackageExample();
276
mh = mh.bindTo(g);
277
mh = mh.asVarargsCollector(String[].class);
278
279
Assert.assertEquals(mh.type(), MethodType.methodType(String.class,String[].class));
280
Assert.assertEquals((String)mh.invokeExact(new String[]{"A","star","I am looking at","may already have","died"}), "[A,star,I am looking at,may already have,died]");
281
}
282
283
/**
284
* Negative test : asVarargsCollector test using wrong method type
285
* @throws Throwable
286
*/
287
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
288
public void test_asVarargsCollector_SamePackage_Virtual_WrongType() throws Throwable{
289
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"getLength",MethodType.methodType(int.class, String[].class));
290
PackageExamples g = new PackageExamples();
291
mh = mh.bindTo(g);
292
mh = mh.asVarargsCollector(int[].class);
293
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong method type");
294
}
295
296
/**
297
* asVarargsCollector test using Arrays.deepToString method
298
* @throws Throwable
299
*/
300
@Test(groups = { "level.extended" })
301
public void test_asVarargsCollector_SamePackage_Static_Array() throws Throwable{
302
MethodHandle mh = MethodHandles.lookup().findStatic(Arrays.class,"deepToString",MethodType.methodType(String.class, Object[].class));
303
mh = mh.asVarargsCollector(Object[].class);
304
305
Assert.assertEquals((String)mh.invoke((Object) new Object[] {"There", "is", "nothing", "outside of text"}), "[[There, is, nothing, outside of text]]");
306
}
307
308
/**
309
* Basic asVarargsCollector test using a virtual method in a class living in a different package (uses MethodHandle.invoke)
310
* @throws Throwable
311
*/
312
@Test(groups = { "level.extended" })
313
public void test_asVarargsCollector_CrossPackage_Virtual_Invoke() throws Throwable {
314
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"getLength",MethodType.methodType(int.class, String[].class));
315
PackageExamples g = new PackageExamples();
316
mh = mh.bindTo(g);
317
mh = mh.asVarargsCollector(String[].class);
318
319
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,String[].class));
320
Assert.assertEquals(mh.invoke("A","star","I am looking at","may already have","died","long ago"), 6);
321
}
322
323
/**
324
* Basic asVarargsCollector test using a virtual method in a class living in a different package (uses MethodHandle.invokeExact)
325
* @throws Throwable
326
*/
327
@Test(groups = { "level.extended" })
328
public void test_asVarargsCollector_CrossPackage_Virtual_InvokeExact() throws Throwable {
329
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"getLength",MethodType.methodType(int.class, String[].class));
330
PackageExamples g = new PackageExamples();
331
mh = mh.bindTo(g);
332
mh = mh.asVarargsCollector(String[].class);
333
334
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,String[].class));
335
Assert.assertEquals((int)mh.invokeExact(new String[]{"A","star","I am looking at","may already have","died"}), 5);
336
}
337
338
/**
339
* Basic asVarargsCollector test using static method living in a class of a different package
340
* @throws Throwable
341
*/
342
@Test(groups = { "level.extended" })
343
public void test_asVarargsCollector_CrossPackage_Static() throws Throwable{
344
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"getLengthStatic",MethodType.methodType(int.class, String[].class));
345
mh = mh.asVarargsCollector(String[].class);
346
347
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,String[].class));
348
Assert.assertEquals((int)mh.invoke("A","star","I am looking at","may already have","died"), 5);
349
}
350
351
/**
352
* Negative test : asVarargsCollector test using wrong type and a virtual method belonging to a class in a different package
353
* @throws Throwable
354
*/
355
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
356
public void test_asVarargsCollector_CrossPackage_Virtual_WrongType() throws Throwable{
357
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"getLength",MethodType.methodType(int.class, String[].class));
358
PackageExamples g = new PackageExamples();
359
mh = mh.bindTo(g);
360
mh = mh.asVarargsCollector(int[].class);
361
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong method type");
362
}
363
364
/**
365
* Negative test : asVarargsCollector test using wrong method type and virtual method living in a class of a different package
366
* @throws Throwable
367
*/
368
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
369
public void test_asVarargsCollector_CrossPackage_Virtual_WrongType_nonArrayTarget() throws Throwable{
370
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"addPublic",MethodType.methodType(int.class, int.class, int.class));
371
PackageExamples g = new PackageExamples();
372
mh = mh.bindTo(g);
373
mh = mh.asVarargsCollector(int[].class);
374
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong method type");
375
}
376
377
/**
378
* asVarargsCollector test for compatible array types - ie: MH takes Object[], asCollector it to String[]
379
* @throws Throwable
380
*/
381
@Test(groups = { "level.extended" })
382
public void test_asVarargsCollector_CompatibleArrayTypes_StringToObject() throws Throwable {
383
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class,Object[].class));
384
SamePackageExample g = new SamePackageExample();
385
mh = mh.bindTo(g);
386
mh = mh.asVarargsCollector(String[].class);
387
Assert.assertEquals((String)mh.invoke("a","b"), "[a,b]");
388
}
389
390
/**
391
* asVarargsCollectorTest for the special case of a MH with Object as the final arg - asCollector that to an array
392
* @throws Throwable
393
*/
394
@Test(groups = { "level.extended" })
395
public void test_asVarargsCollector_TypeCompatibility_Array_Object() throws Throwable {
396
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"toOjectArrayString",MethodType.methodType(String.class,Object.class));
397
SamePackageExample g = new SamePackageExample();
398
mh = mh.bindTo(g);
399
mh = mh.asVarargsCollector(Object[].class);
400
Assert.assertEquals(mh.invoke("a",1000,true,1.1,Long.MAX_VALUE,Short.MIN_VALUE), "[a,1000,true,1.1,9223372036854775807,-32768]");
401
}
402
403
404
/******************************
405
* Tests for asSpreader
406
* ****************************/
407
408
/**
409
* Basic asSpreader test using a virtual method in the same package
410
* @throws Throwable
411
*/
412
@Test(groups = { "level.extended" })
413
public void test_asSpreader_SamePackage_Virtual() throws Throwable{
414
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"addPublic",MethodType.methodType(int.class,int.class,int.class));
415
SamePackageExample g = new SamePackageExample();
416
mh = mh.bindTo(g);
417
mh = mh.asSpreader(int[].class, 2);
418
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,int[].class));
419
Assert.assertEquals((int)mh.invokeExact(new int[] {3,2}), 5);
420
}
421
422
/**
423
* Negative test : asSpreader test using wrong method type for a virtual method in the same package
424
* @throws Throwable
425
*/
426
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
427
public void test_asSpreader_SamePackage_Virtual_WrongType() throws Throwable{
428
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"addPublic",MethodType.methodType(int.class,int.class,int.class));
429
SamePackageExample g = new SamePackageExample();
430
mh = mh.bindTo(g);
431
mh = mh.asSpreader(String[].class, 2);
432
Assert.fail("The test case failed to throw an WrongMethodTypeException in the case of the wrong method type");
433
}
434
435
/**
436
* Negative test : asSpreader test using wrong argument count for the target method
437
* @throws Throwable
438
*/
439
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
440
public void test_asSpreader_SamePackage_Virtual_WrongArgCount() throws Throwable{
441
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"addPublic",MethodType.methodType(int.class,int.class,int.class));
442
SamePackageExample g = new SamePackageExample();
443
mh = mh.bindTo(g);
444
mh = mh.asSpreader(int[].class, 3);
445
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong method type");
446
}
447
448
/**
449
* asSpreader test using static method of a class living in the same package
450
* @throws Throwable
451
*/
452
@Test(groups = { "level.extended" })
453
public void test_asSpreader_SamePackage_Static() throws Throwable{
454
MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class,"addPublicStatic",MethodType.methodType(int.class,int.class,int.class));
455
mh = mh.asSpreader(int[].class, 2);
456
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,int[].class));
457
Assert.assertEquals((int)mh.invokeExact(new int[] {3,2}), 5);
458
}
459
460
/**
461
* Negative test : asSpreader test using wrong method type for a static method belonging to a class in the same package
462
* @throws Throwable
463
*/
464
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
465
public void test_asSpreader_SamePackage_Static_WrongType() throws Throwable{
466
MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class,"addPublicStatic",MethodType.methodType(int.class,int.class,int.class));
467
mh = mh.asSpreader(int[].class, 2);
468
mh = mh.asSpreader(String[].class, 2);
469
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong method type");
470
}
471
472
/**
473
* Basic asSpreader test using cross package virtual method
474
* @throws Throwable
475
*/
476
@Test(groups = { "level.extended" })
477
public void test_asSpreader_CrossPackage_Virtual() throws Throwable{
478
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"addPublic",MethodType.methodType(int.class,int.class,int.class));
479
PackageExamples g = new PackageExamples();
480
mh = mh.bindTo(g);
481
mh = mh.asSpreader(int[].class, 2);
482
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,int[].class));
483
Assert.assertEquals((int)mh.invokeExact(new int[] {3,2}), 5);
484
}
485
486
/**
487
* Basic asSpreader test using cross package static method
488
* @throws Throwable
489
*/
490
@Test(groups = { "level.extended" })
491
public void test_asSpreader_CrossPackage_Static() throws Throwable{
492
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStatic",MethodType.methodType(int.class,int.class,int.class));
493
mh = mh.asSpreader(int[].class, 2);
494
Assert.assertEquals(mh.type(), MethodType.methodType(int.class,int[].class));
495
Assert.assertEquals((int)mh.invokeExact(new int[] {3,2}), 5);
496
}
497
498
/**
499
* Negative test : asSpreader test using cross package virtual method with a wrong method type
500
* @throws Throwable
501
*/
502
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
503
public void test_asSpreader_CrossPackage_Virtual_WrongType() throws Throwable{
504
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"addPublic",MethodType.methodType(int.class,int.class,int.class));
505
PackageExamples g = new PackageExamples();
506
mh = mh.bindTo(g);
507
mh = mh.asSpreader(String[].class, 2);
508
Assert.fail("The test case failed to throw an WrongMethodTypeException in the case of the wrong method type");
509
}
510
511
/**
512
* Negative test : asSpreader test using a cross-package static method and wrong method type
513
* @throws Throwable
514
*/
515
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
516
public void test_asSpreader_CrossPackage_Static_WrongType() throws Throwable{
517
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStatic",MethodType.methodType(int.class,int.class,int.class));
518
mh = mh.asSpreader(int[].class, 2);
519
mh = mh.asSpreader(String[].class, 2);
520
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong method type");
521
}
522
523
/**
524
* Negative test : asSpreader test using cross package static method and a wrong argument count
525
* @throws Throwable
526
*/
527
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
528
public void test_asSpreader_CrossPackage_Static_WrongArgCount() throws Throwable{
529
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStatic",MethodType.methodType(int.class,int.class,int.class));
530
mh = mh.asSpreader(int[].class, 3);
531
Assert.fail("The test case failed to throw an IllegalArgumentException in the case of the wrong argument count");
532
}
533
534
/******************************
535
* Tests for MethodHandle arity
536
* ****************************/
537
/**
538
* Create MethodHandle with highest possible arity and use findConstructor (253)
539
* @throws Throwable
540
*/
541
@Test(groups = { "level.extended" })
542
public void test_findConstructor_ArityLimit() throws Throwable {
543
MethodHandle mh = MethodHandles.lookup().findConstructor(HelperConstructorClass.class, helperMethodType_void_253int);
544
mh = mh.asSpreader(int[].class, 253);
545
}
546
547
/**
548
* Negative test: Create MethodHandle with highest possible arity + 1 (254)
549
* @throws Throwable
550
*/
551
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
552
public void test_findConstructor_ArityLimit_TooHigh() throws Throwable {
553
MethodHandles.lookup().findConstructor(HelperConstructorClass.class, helperMethodType_void_254int);
554
Assert.fail("The test case failed to detect that the argument slots exceeds the upper limit (255)");
555
}
556
557
/**
558
* Create MethodHandle with highest possible arity and use asSpreader (253)
559
* @throws Throwable
560
*/
561
@Test(groups = { "level.extended" })
562
public void test_asSpreader_ArityLimit() throws Throwable {
563
MethodHandle mh = null;
564
mh = MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperSpreaderMethod_253arg", helperMethodType_void_253int);
565
mh = mh.asSpreader(int[].class, 253);
566
}
567
568
/**
569
* Create static MethodHandle with highest possible arity and use asSpreader (254)
570
* @throws Throwable
571
*/
572
@Test(groups = { "level.extended" })
573
public void test_asSpreader_Static_ArityLimit() throws Throwable {
574
MethodHandle mh = null;
575
mh = MethodHandles.lookup().findStatic(MethodHandleTest.class, "helperSpreaderStaticMethod_254arg", helperMethodType_void_254int);
576
mh = mh.asSpreader(int[].class, 254);
577
}
578
579
/**
580
* Negative test: Create MethodHandle with highest possible arity + 1 (254)
581
* @throws Throwable
582
*/
583
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
584
public void test_MethodHandle_ArityLimit_TooHigh() throws Throwable {
585
MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperSpreaderMethod_254arg", helperMethodType_void_254int);
586
Assert.fail("The test case failed to detect that the argument slots exceeds the upper limit (255)");
587
}
588
589
/**
590
* Negative test: Create static MethodHandle with highest possible arity + 1 (255)
591
* @throws Throwable
592
*/
593
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
594
public void test_MethodHandle_Static_ArityLimit_TooHigh() throws Throwable {
595
MethodHandles.lookup().findStatic(MethodHandleTest.class, "helperSpreaderStaticMethod_255arg", helperMethodType_void_255int);
596
Assert.fail("The test case failed to detect that the argument slots exceeds the upper limit (255)");
597
}
598
599
/**
600
* Create MethodHandle with highest possible arity using asCollector (253)
601
* @throws Throwable
602
*/
603
@Test(groups = { "level.extended" })
604
public void test_asCollector_ArityLimit() throws Throwable {
605
MethodHandle mh = MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperCollectorMethod", MethodType.methodType(void.class,int[].class));
606
mh = mh.asCollector(int[].class, 253);
607
}
608
609
/**
610
* Negative test: Create MethodHandle with highest possible arity + 1 using asCollector (254)
611
* @throws Throwable
612
*/
613
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
614
public void test_asCollector_ArityLimit_TooHigh() throws Throwable {
615
MethodHandle mh = MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperCollectorMethod", MethodType.methodType(void.class, int[].class));
616
mh = mh.asCollector(int[].class, 254);
617
Assert.fail("The test case failed to detect that the argument slots exceeds the upper limit (255)");
618
}
619
620
/**
621
* Create MethodHandle with highest possible arity using asCollector (254)
622
* @throws Throwable
623
*/
624
@Test(groups = { "level.extended" })
625
public void test_asCollector_Static_ArityLimit() throws Throwable {
626
MethodHandle mh = MethodHandles.lookup().findStatic(MethodHandleTest.class, "helperStaticCollectorMethod", MethodType.methodType(void.class, int[].class));
627
mh = mh.asCollector(int[].class, 254);
628
}
629
630
/**
631
* Negative test: Create MethodHandle with highest possible arity + 1 using asCollector (255)
632
* @throws Throwable
633
*/
634
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
635
public void test_asCollector_Static_ArityLimit_TooHigh() throws Throwable {
636
MethodHandle mh = MethodHandles.lookup().findStatic(MethodHandleTest.class, "helperStaticCollectorMethod", MethodType.methodType(void.class, int[].class));
637
mh = mh.asCollector(int[].class, 255);
638
Assert.fail("The test case failed to detect that the argument slots exceeds the upper limit (255)");
639
}
640
641
/**
642
* Create spreadInvoker with highest possible arity (253)
643
* @throws Throwable
644
*/
645
@Test(groups = { "level.extended" })
646
public void test_spreadInvoker_ArityLimit() throws Throwable {
647
final int args = 252;
648
MethodHandle mh = MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperSpreaderMethod_" + args + "arg", helperMethodType_void_252int);
649
MethodHandle invoker = MethodHandles.spreadInvoker(helperMethodType_void_252int.insertParameterTypes(0, MethodHandleTest.class), 1);
650
Object[] a = new Object[args];
651
for (int i = 0; i < args; i++) {
652
a[i] = 0;
653
}
654
invoker.invoke(mh, new MethodHandleTest(), a);
655
}
656
657
/**
658
* Create spreadInvoker with highest possible arity 254)
659
* @throws Throwable
660
*/
661
@Test(groups = { "level.extended" })
662
public void test_spreadInvoker_Static_ArityLimit() throws Throwable {
663
final int args = 253;
664
MethodHandle mh = MethodHandles.lookup().findStatic(MethodHandleTest.class, "helperSpreaderStaticMethod_" + args + "arg", helperMethodType_void_253int);
665
MethodHandle invoker = MethodHandles.spreadInvoker(helperMethodType_void_253int, 0);
666
Object[] a = new Object[args];
667
for (int i = 0; i < args; i++) {
668
a[i] = 0;
669
}
670
invoker.invoke(mh, a);
671
}
672
673
/**
674
* Create exactInvoker with highest possible arity (252)
675
* @throws Throwable
676
*/
677
@Test(groups = { "level.extended" })
678
public void test_exactInvoker_ArityLimit() throws Throwable {
679
final int args = 252;
680
MethodHandle mh = MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperSpreaderMethod_" + args + "arg", helperMethodType_void_252int);
681
MethodHandle invoker = MethodHandles.exactInvoker(helperMethodType_void_252int.insertParameterTypes(0, MethodHandleTest.class));
682
invoker.invokeExact(mh, new MethodHandleTest(),
683
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
684
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
685
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
686
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
687
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
688
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
689
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
690
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
691
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
692
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
693
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
694
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
695
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
696
}
697
698
/**
699
* Create static exactInvoker with highest possible arity (253)
700
* @throws Throwable
701
*/
702
@Test(groups = { "level.extended" })
703
public void test_exactInvoker_Static_ArityLimit() throws Throwable {
704
final int args = 253;
705
MethodHandle mh = MethodHandles.lookup().findStatic(MethodHandleTest.class, "helperSpreaderStaticMethod_" + args + "arg", helperMethodType_void_253int);
706
MethodHandle invoker = MethodHandles.exactInvoker(helperMethodType_void_253int);
707
invoker.invokeExact(mh,
708
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
709
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
710
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
711
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
712
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
713
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
714
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
715
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
716
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
717
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
718
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
719
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
720
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
721
}
722
723
/**
724
* Negative test: Create exactInvoker with highest possible arity + 1 (253)
725
* @throws Throwable
726
*/
727
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
728
public void test_exactInvoker_ArityLimit_TooHigh() throws Throwable {
729
MethodHandles.exactInvoker(helperMethodType_void_253int.insertParameterTypes(0, MethodHandleTest.class));
730
Assert.fail("The test case failed to detect that the argument slots exceeds the upper limit (255)");
731
}
732
733
/**
734
* Negative test: Create static exactInvoker with highest possible arity + 1 (254)
735
* @throws Throwable
736
*/
737
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
738
public void test_exactInvoker_Static_ArityLimit_TooHigh() throws Throwable {
739
MethodHandles.exactInvoker(helperMethodType_void_254int);
740
Assert.fail("The test case failed to detect that the argument slots exceeds the upper limit (255)");
741
}
742
743
/**
744
* Create invoker with highest possible arity (252)
745
* @throws Throwable
746
*/
747
@Test(groups = { "level.extended" })
748
public void test_invoker_ArityLimit() throws Throwable {
749
final int args = 252;
750
MethodHandle mh = MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperSpreaderMethod_" + args + "arg", helperMethodType_void_252int);
751
MethodHandle invoker = MethodHandles.invoker(helperMethodType_void_252int.insertParameterTypes(0, MethodHandleTest.class));
752
invoker.invoke(mh, new MethodHandleTest(),
753
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
754
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
755
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
756
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
757
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
758
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
759
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
760
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
761
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
762
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
763
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
764
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
765
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
766
}
767
768
/**
769
* Create invoker with highest possible arity (253)
770
* @throws Throwable
771
*/
772
@Test(groups = { "level.extended" })
773
public void test_invoker_Static_ArityLimit() throws Throwable {
774
final int args = 253;
775
MethodHandle mh = MethodHandles.lookup().findStatic(MethodHandleTest.class, "helperSpreaderStaticMethod_" + args + "arg", helperMethodType_void_253int);
776
MethodHandle invoker = MethodHandles.invoker(helperMethodType_void_253int);
777
invoker.invoke(mh,
778
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
779
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
780
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
781
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
782
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
783
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
784
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
785
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
786
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
787
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
788
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
789
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
790
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
791
}
792
793
/**
794
* Negative test: Create invoker with highest possible arity + 1 (253)
795
* @throws Throwable
796
*/
797
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
798
public void test_invoker_ArityLimit_TooHigh() throws Throwable {
799
MethodHandles.invoker(helperMethodType_void_253int.insertParameterTypes(0, MethodHandleTest.class));
800
Assert.fail("The test case failed to detect that the argument slots exceeds the upper limit (255)");
801
}
802
803
/**
804
* Negative test: Create static invoker with highest possible arity + 1 (254)
805
* @throws Throwable
806
*/
807
@Test(expectedExceptions = IllegalArgumentException.class, groups = { "level.extended" })
808
public void test_invoker_Static_ArityLimit_TooHigh() throws Throwable {
809
MethodHandles.invoker(helperMethodType_void_254int);
810
Assert.fail("The test case failed to detect that the argument slots exceeds the upper limit (255)");
811
}
812
813
@Test(groups = { "level.extended" })
814
public void test_invokeWithArguments_ArityLimit() throws Throwable {
815
MethodHandle mh = MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperSpreaderMethod_253arg", helperMethodType_void_253int);
816
mh.invokeWithArguments(new MethodHandleTest(),
817
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
818
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
819
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
820
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
821
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
822
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
823
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
824
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
825
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
826
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
827
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
828
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
829
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
830
}
831
832
@Test(groups = { "level.extended" })
833
public void test_invokeWithArguments_Static_ArityLimit() throws Throwable {
834
MethodHandle mh = MethodHandles.lookup().findStatic(MethodHandleTest.class, "helperSpreaderStaticMethod_254arg", helperMethodType_void_254int);
835
mh.invokeWithArguments(
836
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
837
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
838
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
839
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
840
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
841
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
842
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
843
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
844
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
845
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
846
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
847
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
848
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
849
}
850
851
/**
852
* 252 characters: below character limit for variable arity invokeWithArguments.
853
* @throws Throwable
854
*/
855
@Test(groups = { "level.extended" })
856
public void test_invokeWithArguments_VarArgs_SmallArityLimit() throws Throwable {
857
MethodHandle mh = MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperVarArgsMethod",
858
MethodType.methodType(void.class, String.class, int[].class));
859
mh.invokeWithArguments(new MethodHandleTest(), "test",
860
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
861
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
862
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
863
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
864
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
865
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
866
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
867
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
868
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
869
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
870
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
871
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
872
0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
873
}
874
875
/**
876
* 254 characters: the maximum number of characters for a variable arity MethodHandle.
877
* @throws Throwable
878
*/
879
@Test(groups = { "level.extended" })
880
public void test_invokeWithArguments_VarArgs_EdgeArityLimit() throws Throwable {
881
MethodHandle mh = MethodHandles.lookup().findVirtual(MethodHandleTest.class, "helperVarArgsMethod",
882
MethodType.methodType(void.class, String.class, int[].class));
883
mh.invokeWithArguments(new MethodHandleTest(), "test",
884
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
885
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
886
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
887
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
888
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
889
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
890
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
891
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
892
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
893
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
894
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
895
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
896
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
897
}
898
899
/******************************
900
* Tests for asFixedArity
901
* ****************************/
902
903
/**
904
* asFixedArity test to ensure MethodHandles.lookup().find* methods returned varargs handles for methods with the ACC_VARARGS bit
905
* @throws Throwable
906
*/
907
@Test(groups = { "level.extended" })
908
public void test_asFixedArity_Using_VariableArity_JavaMethod_Virtual_SamePackage() throws Throwable {
909
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"takeVariableArityObject", MethodType.methodType(void.class, Object[].class));
910
SamePackageExample g = new SamePackageExample();
911
912
Assert.assertTrue(mh.isVarargsCollector());
913
914
mh = mh.asFixedArity();
915
916
//Ensure after calling asFixedArity, it is no longer a varargs handles
917
Assert.assertFalse(mh.isVarargsCollector());
918
919
Assert.assertEquals(mh.invoke(g,new Object[]{new Object[]{"abc",true,12}}), null);
920
}
921
922
/**
923
* Basic asFixedArity test using a same-package static method
924
* @throws Throwable
925
*/
926
@Test(groups = { "level.extended" })
927
public void test_asFixedArity_SamePackage_Static() throws Throwable {
928
MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class, "getLengthStatic", MethodType.methodType(int.class,String[].class));
929
mh = mh.asVarargsCollector(String[].class);
930
MethodHandle mhFix = mh.asFixedArity();
931
932
Assert.assertFalse(mhFix.isVarargsCollector());
933
Assert.assertEquals(mhFix.invoke(new String[]{"a","b","c","d","e"}), 5);
934
}
935
936
/**
937
* Negative test : asFixedArity test using variable input
938
* @throws Throwable
939
*/
940
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
941
public void test_asFixedArity_SamePackage_Static_VarialbeInput() throws Throwable {
942
MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class, "getLengthStatic", MethodType.methodType(int.class,String[].class));
943
mh = mh.asVarargsCollector(String[].class);
944
945
MethodHandle mhFix = mh.asFixedArity();
946
947
Assert.assertFalse(mhFix.isVarargsCollector());
948
949
mhFix.invoke("a","b","c","d","e");
950
Assert.fail("The test case failed to throw an WrongMethodTypeException in using variable input");
951
}
952
953
954
/****************************************
955
* Tests for invokeWithArguments(List<?>)
956
* **************************************/
957
958
public static String helper_invokeWithArguments_List_Different_Array_Type(Object a, Object b, Object c) {
959
return "" + a + ":" + b + ":" + c;
960
}
961
962
/**
963
* Basic invokeWithArgument(List<?>) test using same-package virtual method
964
* @throws Throwable
965
*/
966
@Test(groups = { "level.extended" })
967
public void test_invokeWithArguments_List_Different_Array_Type() throws Throwable {
968
MethodHandle mh = MethodHandles.lookup().findStatic(
969
MethodHandleTest.class,
970
"helper_invokeWithArguments_List_Different_Array_Type",
971
MethodType.methodType(String.class, Object.class,Object.class,Object.class));
972
String result = (String)mh.invokeWithArguments(Arrays.asList("A", "B", "C"));
973
Assert.assertEquals(result, "A:B:C");
974
}
975
976
/**
977
* Basic invokeWithArgument(List<?>) test using same-package virtual method
978
* @throws Throwable
979
*/
980
@Test(groups = { "level.extended" })
981
public void test_invokeWithArguments_List_SamePackage_Virtual() throws Throwable{
982
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class, "addPublic", MethodType.methodType(int.class,int.class,int.class));
983
SamePackageExample g = new SamePackageExample();
984
mh = mh.bindTo(g);
985
986
List<Integer> l = new ArrayList<Integer>();
987
l.add(1);
988
l.add(2);
989
990
Assert.assertEquals((int)mh.invokeWithArguments(l), 3);
991
}
992
993
/**
994
* Negative test : invokeWithArgument(List<?>) test with mismatched number of argument passed in argument list
995
* @throws Throwable
996
*/
997
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
998
public void test_invokeWithArguments_List_SamePackage_Virtual_WrongArgCount() throws Throwable{
999
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class, "addPublic", MethodType.methodType(int.class,int.class,int.class));
1000
SamePackageExample g = new SamePackageExample();
1001
mh = mh.bindTo(g);
1002
1003
List<Integer> l = new ArrayList<Integer>();
1004
l.add(1);
1005
l.add(2);
1006
l.add(3);
1007
1008
mh.invokeWithArguments(l);
1009
Assert.fail("The test case failed to throw an WrongMethodTypeException in the case of mismatched number of argument");
1010
}
1011
1012
/**
1013
* invokeWithArgument(List<?>) test using a same-package static method
1014
* @throws Throwable
1015
*/
1016
@Test(groups = { "level.extended" })
1017
public void test_invokeWithArguments_List_SamePackage_Static() throws Throwable{
1018
MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class, "addPublicStatic", MethodType.methodType(int.class,int.class,int.class));
1019
1020
List<Integer> l = new ArrayList<Integer>();
1021
l.add(1);
1022
l.add(2);
1023
1024
Assert.assertEquals((int)mh.invokeWithArguments(l), 3);
1025
}
1026
1027
/**
1028
* invokeWithArgument(List<?>) test using a cross-package virtual method
1029
* @throws Throwable
1030
*/
1031
@Test(groups = { "level.extended" })
1032
public void test_invokeWithArguments_List_CrossPackage_Virtual() throws Throwable{
1033
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class, "addPublic", MethodType.methodType(int.class,int.class,int.class));
1034
PackageExamples g = new PackageExamples();
1035
mh = mh.bindTo(g);
1036
1037
List<Integer> l = new ArrayList<Integer>();
1038
l.add(1);
1039
l.add(2);
1040
1041
Assert.assertEquals((int)mh.invokeWithArguments(l), 3);
1042
}
1043
1044
/**
1045
* invokeWithArgument(List<?>) test using a cross-package static method
1046
* @throws Throwable
1047
*/
1048
@Test(groups = { "level.extended" })
1049
public void test_invokeWithArguments_List_CrossPackage_Static() throws Throwable{
1050
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class, "addPublicStatic", MethodType.methodType(int.class,int.class,int.class));
1051
1052
List<Integer> l = new ArrayList<Integer>();
1053
l.add(1);
1054
l.add(2);
1055
1056
Assert.assertEquals((int)mh.invokeWithArguments(l), 3);
1057
}
1058
1059
1060
/****************************************
1061
* Tests for invokeWithArguments(Object...)
1062
* **************************************/
1063
1064
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1065
public void test_invokeWithArguments_WMT_NULL_args() throws Throwable {
1066
MethodHandle mh = MethodHandles.lookup().findVirtual(Object.class, "toString", MethodType.methodType(String.class));
1067
mh.invokeWithArguments("receiver", null, null);
1068
Assert.fail("The test case failed to throw an WrongMethodTypeException in the case of null arguments");
1069
}
1070
1071
/**
1072
* invokeWithArguments(Object... args) test using a same-package virtual method
1073
* @throws Throwable
1074
*/
1075
@Test(groups = { "level.extended" })
1076
public void test_invokeWithArguments_VarargsObj_SamePackage_Virtual() throws Throwable{
1077
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class, "addPublic", MethodType.methodType(int.class,int.class,int.class));
1078
SamePackageExample g = new SamePackageExample();
1079
1080
Assert.assertEquals((int)mh.invokeWithArguments(g,1,2), 3);
1081
}
1082
1083
/**
1084
* invokeWithArguments(Object... args) test to ensure that the varargsCollector behavior is respected by the invokeWithArguments call
1085
* @throws Throwable
1086
*/
1087
@Test(groups = { "level.extended" })
1088
public void test_invokeWithArguments_VarargsObj_SamePackage_Virtual_VarargsMethod() throws Throwable{
1089
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class, "addPublicVariableArity", MethodType.methodType(int.class,Object[].class));
1090
SamePackageExample g = new SamePackageExample();
1091
1092
Assert.assertTrue(mh.isVarargsCollector());
1093
1094
Assert.assertEquals(mh.invokeWithArguments(g, 1, 2, 2, 2, 2), 9);
1095
}
1096
1097
/**
1098
* Negative test : invokeWithArguments(Object... args) with wrong argument type
1099
* @throws Throwable
1100
*/
1101
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1102
public void test_invokeWithArguments_VarargsObj_SamePackage_Virtual_WrongArgCount() throws Throwable{
1103
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class, "addPublic", MethodType.methodType(int.class,int.class,int.class));
1104
SamePackageExample g = new SamePackageExample();
1105
mh = mh.bindTo(g);
1106
mh.invokeWithArguments(1,2,3);
1107
Assert.fail("The test case failed to throw an WrongMethodTypeException in the case of wrong argument type");
1108
}
1109
1110
/**
1111
* invokeWithArguments(Object... args) test with same-package static method
1112
* @throws Throwable
1113
*/
1114
@Test(groups = { "level.extended" })
1115
public void test_invokeWithArguments_VarargsObj_SamePackage_Static() throws Throwable{
1116
MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class, "addPublicStatic", MethodType.methodType(int.class,int.class,int.class));
1117
1118
Object [] l = new Object[2];
1119
l[0] = 1;
1120
l[1] = 2;
1121
1122
Assert.assertEquals((int)mh.invokeWithArguments(l), 3);
1123
}
1124
1125
/**
1126
* invokeWithArguments(Object... args) with cross-package virtual method
1127
* @throws Throwable
1128
*/
1129
@Test(groups = { "level.extended" })
1130
public void test_invokeWithArguments_VarargsObj_CrossPackage_Virtual() throws Throwable{
1131
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class, "addPublic", MethodType.methodType(int.class,int.class,int.class));
1132
PackageExamples g = new PackageExamples();
1133
mh = mh.bindTo(g);
1134
1135
Object [] l = new Object[2];
1136
l[0] = 1;
1137
l[1] = 2;
1138
1139
Assert.assertEquals((int)mh.invokeWithArguments(l), 3);
1140
}
1141
1142
/**
1143
* invokeWithArguments(Object... args) with cross-package static method
1144
* @throws Throwable
1145
*/
1146
@Test(groups = { "level.extended" })
1147
public void test_invokeWithArguments_VarargsObj_CrossPackage_Static() throws Throwable{
1148
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class, "addPublicStatic", MethodType.methodType(int.class,int.class,int.class));
1149
1150
Object [] l = new Object[2];
1151
l[0] = 1;
1152
l[1] = 2;
1153
1154
Assert.assertEquals((int)mh.invokeWithArguments(l), 3);
1155
}
1156
1157
/**
1158
* invokeWithArguments(Object... args) test with Corner case of 0 length array
1159
* @throws Throwable
1160
*/
1161
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1162
public void test_invokeWithArguments_VarargsObj_CrossPackage_Static_ZeroLengthArray() throws Throwable{
1163
MethodHandle mh = MethodHandles.lookup().findStatic(SamePackageExample.class, "returnOne", MethodType.methodType(String.class));
1164
1165
Object [] l = new Object[0];
1166
1167
Assert.assertEquals((String)mh.invokeWithArguments(l), "1");
1168
1169
MethodHandle mh2 = MethodHandles.lookup().findStatic(SamePackageExample.class, "addPublicStatic", MethodType.methodType(int.class,int.class,int.class));
1170
1171
Object [] l2 = new Object[0];
1172
1173
mh2.invokeWithArguments(l2);
1174
Assert.fail("The test case failed to throw an WrongMethodTypeException in the case of 0 length array");
1175
}
1176
1177
/****************************************
1178
* Tests for isVarargsCollector
1179
* **************************************/
1180
1181
/**
1182
* Test isVarargsCollector using a call to asVarargsCollector
1183
* @throws Throwable
1184
*/
1185
@Test(groups = { "level.extended" })
1186
public void test_isVarargsCollector_Using_asVarargsCollector_Virtual_SamePackage() throws Throwable{
1187
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class, String[].class));
1188
SamePackageExample g = new SamePackageExample();
1189
mh = mh.bindTo(g);
1190
mh = mh.asVarargsCollector(String[].class);
1191
1192
Assert.assertTrue(mh.isVarargsCollector());
1193
}
1194
1195
/**
1196
* Negative test : isVarargsCollector test using asCollector call
1197
* @throws Throwable
1198
*/
1199
@Test(groups = { "level.extended" })
1200
public void test_isVarargsCollector_Using_asCollector_Virtual_SamePackage() throws Throwable{
1201
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class, String[].class));
1202
SamePackageExample g = new SamePackageExample();
1203
mh = mh.bindTo(g);
1204
mh = mh.asCollector(String[].class,3);
1205
1206
Assert.assertFalse(mh.isVarargsCollector());
1207
}
1208
1209
/**
1210
* Basic isVarargsCollector test using a cross-package static method
1211
* @throws Throwable
1212
*/
1213
@Test(groups = { "level.extended" })
1214
public void test_isVarargsCollector_Using_asVarargsCollector_Static_CrossPackage() throws Throwable{
1215
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"getLengthStatic",MethodType.methodType(int.class, String[].class));
1216
mh = mh.asVarargsCollector(String[].class);
1217
1218
Assert.assertTrue(mh.isVarargsCollector());
1219
}
1220
1221
/**
1222
* Test isVarargsCollector using a asVarargsCollector type MethodHandle obtained from a call to a lookup method which resolves to a variable arity Java method
1223
* @throws Throwable
1224
*/
1225
@Test(groups = { "level.extended" })
1226
public void test_isVarargsCollector_Using_VariableArity_JavaMethod_Virtual_SamePackage() throws Throwable{
1227
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"addPublicVariableArity",MethodType.methodType(int.class, int[].class));
1228
1229
Assert.assertTrue(mh.isVarargsCollector());
1230
}
1231
1232
/**
1233
* Test isVarargsCollector using MethodHandle obtained from a call to a lookup method which resolves to a variable arity Java constructor
1234
* @throws Throwable
1235
*/
1236
@Test(groups = { "level.extended" })
1237
public void test_isVarargsCollector_Using_VariableArity_JavaConstructor_SamePackage() throws Throwable{
1238
MethodHandle mh = MethodHandles.lookup().findConstructor(SamePackageExample.class,MethodType.methodType(void.class, int[].class));
1239
1240
Assert.assertTrue(mh.isVarargsCollector());
1241
}
1242
1243
/**
1244
* Test isVarargsCollector using a asVarargsCollector type MH obtained from a call to a lookup method which resolves to a variable arity Java method in a different package
1245
* @throws Throwable
1246
*/
1247
@Test(groups = { "level.extended" })
1248
public void test_isVarargsCollector_Using_VariableArity_JavaMethod_Virtual_CrossPackage() throws Throwable{
1249
MethodHandle mh = MethodHandles.lookup().findVirtual(PackageExamples.class,"addPublicVariableArity",MethodType.methodType(int.class, int[].class));
1250
1251
Assert.assertTrue(mh.isVarargsCollector());
1252
}
1253
1254
/**
1255
* Test isVarargsCollector using a asVarargsCollector type MH obtained from a call to a lookup method which resolves to a static variable arity Java method in a different package
1256
* @throws Throwable
1257
*/
1258
@Test(groups = { "level.extended" })
1259
public void test_isVarargsCollector_Using_VariableArity_JavaMethod_Static_CrossPackage() throws Throwable{
1260
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStaticVariableArity",MethodType.methodType(int.class, int[].class));
1261
1262
Assert.assertTrue(mh.isVarargsCollector());
1263
}
1264
1265
/**
1266
* Test isVarargsCollector to ensure that an asVarargsCollector handle that has been asTyped() to the same type still remains asVarargsCollector type
1267
* @throws Throwable
1268
*/
1269
@Test(groups = { "level.extended" })
1270
public void test_isVarargsCollector_Using_asVarargsCollector_asTyped() throws Throwable {
1271
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStaticVariableArity",MethodType.methodType(int.class, int[].class));
1272
1273
Assert.assertTrue(mh.isVarargsCollector());
1274
1275
mh = mh.asType(MethodType.methodType(int.class,int[].class));
1276
1277
Assert.assertTrue(mh.isVarargsCollector());
1278
}
1279
1280
/**
1281
* Ensure that an asVarargsCollector handle that has been asTyped() to a different type no longer remains asVarargsCollector type
1282
* Change type of argument from int --> byte
1283
* @throws Throwable
1284
*/
1285
@Test(groups = { "level.extended" })
1286
public void test_isVarargsCollector_Using_asVarargsCollector_asTyped_arg_int_to_byte() throws Throwable {
1287
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStaticVariableArity",MethodType.methodType(int.class, int[].class));
1288
1289
Assert.assertTrue(mh.isVarargsCollector());
1290
1291
mh = mh.asType(MethodType.methodType(int.class,byte.class));
1292
1293
Assert.assertFalse(mh.isVarargsCollector());
1294
}
1295
1296
/**
1297
* Ensure that an asVarargsCollector handle that has been asTyped() to a different type no longer remains asVarargsCollector type
1298
* Negative test : Change return type from int --> byte : This should throw exception as return types can only be converted from small to big types
1299
* @throws Throwable
1300
*/
1301
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1302
public void test_isVarargsCollector_Using_asVarargsCollector_asTyped_RT_int_to_byte() throws Throwable {
1303
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStaticVariableArity",MethodType.methodType(int.class, int[].class));
1304
1305
Assert.assertTrue(mh.isVarargsCollector());
1306
1307
mh = mh.asType(MethodType.methodType(byte.class,int[].class));
1308
Assert.fail("The test case failed to throw an WrongMethodTypeException as return types can only be converted from small to big types");
1309
}
1310
1311
/**
1312
* Ensure that an asVarargsCollector handle that has been asTyped() to a different type no longer remains asVarargsCollector type
1313
* Change type of argument from int --> short
1314
* @throws Throwable
1315
*/
1316
@Test(groups = { "level.extended" })
1317
public void test_isVarargsCollector_Using_asVarargsCollector_asTyped_arg_int_to_short() throws Throwable {
1318
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStaticVariableArity",MethodType.methodType(int.class, int[].class));
1319
1320
Assert.assertTrue(mh.isVarargsCollector());
1321
1322
mh = mh.asType(MethodType.methodType(int.class,short.class));
1323
1324
Assert.assertFalse(mh.isVarargsCollector());
1325
}
1326
1327
/**
1328
* Ensure that an asVarargsCollector handle that has been asTyped() to a different type no longer remains asVarargsCollector type
1329
* Negative test : Change return type from int --> short : This should throw exception as return types can only be converted from small to big types
1330
* @throws Throwable
1331
*/
1332
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1333
public void test_isVarargsCollector_Using_asVarargsCollector_asTyped_RT_int_to_short() throws Throwable {
1334
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStaticVariableArity",MethodType.methodType(int.class, int[].class));
1335
1336
Assert.assertTrue(mh.isVarargsCollector());
1337
1338
mh = mh.asType(MethodType.methodType(short.class,int[].class));
1339
Assert.fail("The test case failed to throw an WrongMethodTypeException as return types can only be converted from small to big types");
1340
}
1341
1342
/**
1343
* Ensure that an asVarargsCollector handle that has been asTyped() to a different type no longer remains asVarargsCollector type
1344
* Negative test : Change type of argument from int --> long : This is an invalid conversion
1345
* @throws Throwable
1346
*/
1347
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1348
public void test_isVarargsCollector_Using_asVarargsCollector_asTyped_arg_int_to_long() throws Throwable {
1349
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStaticVariableArity",MethodType.methodType(int.class, int[].class));
1350
1351
Assert.assertTrue(mh.isVarargsCollector());
1352
1353
mh = mh.asType(MethodType.methodType(int.class,long.class));
1354
Assert.fail("The test case failed to throw an WrongMethodTypeException in the case of the invalid type conversion from int to long");
1355
}
1356
1357
1358
/**
1359
* Ensure that an asVarargsCollector handle that has been asTyped() to a different type no longer remains asVarargsCollector type
1360
* Change return type from int --> long
1361
* @throws Throwable
1362
*/
1363
@Test(groups = { "level.extended" })
1364
public void test_isVarargsCollector_Using_asVarargsCollector_asTyped_RT_int_to_long() throws Throwable {
1365
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStaticVariableArity",MethodType.methodType(int.class, int[].class));
1366
1367
Assert.assertTrue(mh.isVarargsCollector());
1368
1369
mh = mh.asType(MethodType.methodType(long.class,int[].class));
1370
1371
Assert.assertFalse(mh.isVarargsCollector());
1372
}
1373
1374
/**
1375
* Ensure that an asVarargsCollector handle that has been asTyped() to a different type no longer remains asVarargsCollector type
1376
* Negative test : Change type of argument from int --> double : This is an invalid conversion
1377
* @throws Throwable
1378
*/
1379
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1380
public void test_isVarargsCollector_Using_asVarargsCollector_asTyped_arg_int_to_double() throws Throwable {
1381
MethodHandle mh = MethodHandles.lookup().findStatic(PackageExamples.class,"addPublicStaticVariableArity",MethodType.methodType(int.class, int[].class));
1382
1383
Assert.assertTrue(mh.isVarargsCollector());
1384
1385
mh = mh.asType(MethodType.methodType(int.class,double.class));
1386
Assert.fail("The test case failed to throw an WrongMethodTypeException in the case of the invalid type conversion from int to double");
1387
}
1388
1389
/**
1390
* Tests bindTo by binding non-null and null objects to a MethodHandle
1391
* @throws Throwable
1392
*/
1393
@Test(expectedExceptions = NullPointerException.class, groups = { "level.extended" })
1394
public void testBindTo() throws Throwable {
1395
MethodHandle handle = SamePackageExample.getLookup().findSpecial(SamePackageExample.class, "isReceiverNull", MethodType.methodType(boolean.class), SamePackageExample.class);
1396
1397
Assert.assertFalse((boolean)handle.bindTo(new SamePackageExample()).invokeExact());
1398
1399
boolean b = (boolean)(handle.bindTo(null).invokeExact());
1400
Assert.fail("The test case failed to throw an NullPointerException in the case of null objects");
1401
}
1402
1403
/**
1404
* Negative test for invoke on String as argument
1405
* @throws Throwable
1406
*/
1407
@Test(expectedExceptions = NumberFormatException.class, groups = { "level.extended" })
1408
public void test_Invoke_String() throws Throwable {
1409
MethodHandle handle = MethodHandles.lookup().findStatic(Integer.class, "parseInt", MethodType.methodType(int.class,String.class));
1410
1411
handle.invoke("s");
1412
Assert.fail("The test case failed to throw an NumberFormatException");
1413
}
1414
1415
/**
1416
* Negative test for invoke on Integer as argument
1417
* @throws Throwable
1418
*/
1419
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1420
public void test_Invoke_Int() throws Throwable {
1421
MethodHandle handle = MethodHandles.lookup().findStatic(Integer.class, "parseInt", MethodType.methodType(int.class,String.class));
1422
1423
handle.invoke(5);
1424
Assert.fail("The test case failed to throw an WrongMethodTypeException");
1425
}
1426
1427
/**
1428
* Negative test for invokeExcat on an array of characters as argument
1429
* @throws Throwable
1430
*/
1431
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1432
public void test_InvokeExact_InvalidArgument1() throws Throwable {
1433
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class,Object[].class));
1434
SamePackageExample g = new SamePackageExample();
1435
mh = mh.bindTo(g);
1436
1437
String str = (String)mh.invokeExact("a","b");
1438
Assert.fail("The test case failed to throw an WrongMethodTypeException");
1439
}
1440
1441
/**
1442
* Negative test for invokeExcat on a combination of String array and Integer as argument
1443
* @throws Throwable
1444
*/
1445
@Test(expectedExceptions = WrongMethodTypeException.class, groups = { "level.extended" })
1446
public void test_InvokeExact_InvalidArgument2() throws Throwable {
1447
MethodHandle mh = MethodHandles.lookup().findVirtual(SamePackageExample.class,"arrayToString",MethodType.methodType(String.class,Object[].class));
1448
SamePackageExample g = new SamePackageExample();
1449
mh = mh.bindTo(g);
1450
1451
ArrayList<String> a = new ArrayList<String>();
1452
MethodHandle m = MethodHandles.lookup().findVirtual(ArrayList.class, "add", MethodType.methodType(boolean.class,Object.class));
1453
1454
Object r = (Object)m.invokeExact(a,1);
1455
Assert.fail("The test case failed to throw an WrongMethodTypeException");
1456
}
1457
1458
public static int countArgs(int... args) {
1459
return args.length;
1460
}
1461
1462
@Test(groups = { "level.extended" })
1463
public void test_invokeWithArguments_variable_input() throws Throwable {
1464
MethodHandle MH = MethodHandles.lookup().findStatic( MethodHandleTest.class, "countArgs", MethodType.methodType( int.class, int[].class) );
1465
ArrayList args = new ArrayList();
1466
for ( int i = 0; i < 25; i++ ){
1467
args.add( i );
1468
Assert.assertEquals(MH.invokeWithArguments(args.toArray()), i+1);
1469
}
1470
}
1471
1472
private static MethodType helperMethodType_void_252int = MethodType.methodType(void.class,
1473
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1474
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1475
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1476
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1477
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1478
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1479
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1480
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1481
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1482
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1483
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1484
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1485
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1486
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1487
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1488
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1489
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1490
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1491
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1492
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1493
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1494
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1495
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1496
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1497
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1498
int.class, int.class);
1499
private static MethodType helperMethodType_void_253int = MethodType.methodType(void.class,
1500
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1501
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1502
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1503
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1504
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1505
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1506
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1507
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1508
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1509
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1510
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1511
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1512
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1513
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1514
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1515
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1516
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1517
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1518
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1519
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1520
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1521
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1522
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1523
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1524
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1525
int.class, int.class, int.class);
1526
private static MethodType helperMethodType_void_254int = MethodType.methodType(void.class,
1527
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1528
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1529
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1530
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1531
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1532
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1533
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1534
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1535
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1536
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1537
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1538
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1539
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1540
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1541
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1542
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1543
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1544
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1545
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1546
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1547
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1548
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1549
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1550
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1551
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1552
int.class, int.class, int.class, int.class);
1553
private static MethodType helperMethodType_void_255int = MethodType.methodType(void.class,
1554
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1555
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1556
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1557
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1558
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1559
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1560
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1561
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1562
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1563
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1564
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1565
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1566
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1567
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1568
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1569
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1570
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1571
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1572
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1573
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1574
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1575
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1576
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1577
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1578
int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class, int.class,
1579
int.class, int.class, int.class, int.class ,int.class);
1580
1581
private void helperSpreaderMethod_252arg(
1582
int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
1583
int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20,
1584
int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30,
1585
int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40,
1586
int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50,
1587
int i51, int i52, int i53, int i54, int i55, int i56, int i57, int i58, int i59, int i60,
1588
int i61, int i62, int i63, int i64, int i65, int i66, int i67, int i68, int i69, int i70,
1589
int i71, int i72, int i73, int i74, int i75, int i76, int i77, int i78, int i79, int i80,
1590
int i81, int i82, int i83, int i84, int i85, int i86, int i87, int i88, int i89, int i90,
1591
int i91, int i92, int i93, int i94, int i95, int i96, int i97, int i98, int i99, int i100,
1592
int i101, int i102, int i103, int i104, int i105, int i106, int i107, int i108, int i109, int i110,
1593
int i111, int i112, int i113, int i114, int i115, int i116, int i117, int i118, int i119, int i120,
1594
int i121, int i122, int i123, int i124, int i125, int i126, int i127, int i128, int i129, int i130,
1595
int i131, int i132, int i133, int i134, int i135, int i136, int i137, int i138, int i139, int i140,
1596
int i141, int i142, int i143, int i144, int i145, int i146, int i147, int i148, int i149, int i150,
1597
int i151, int i152, int i153, int i154, int i155, int i156, int i157, int i158, int i159, int i160,
1598
int i161, int i162, int i163, int i164, int i165, int i166, int i167, int i168, int i169, int i170,
1599
int i171, int i172, int i173, int i174, int i175, int i176, int i177, int i178, int i179, int i180,
1600
int i181, int i182, int i183, int i184, int i185, int i186, int i187, int i188, int i189, int i190,
1601
int i191, int i192, int i193, int i194, int i195, int i196, int i197, int i198, int i199, int i200,
1602
int i201, int i202, int i203, int i204, int i205, int i206, int i207, int i208, int i209, int i210,
1603
int i211, int i212, int i213, int i214, int i215, int i216, int i217, int i218, int i219, int i220,
1604
int i221, int i222, int i223, int i224, int i225, int i226, int i227, int i228, int i229, int i230,
1605
int i231, int i232, int i233, int i234, int i235, int i236, int i237, int i238, int i239, int i240,
1606
int i241, int i242, int i243, int i244, int i245, int i246, int i247, int i248, int i249, int i250,
1607
int i251, int i252) {}
1608
private void helperSpreaderMethod_253arg(
1609
int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
1610
int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20,
1611
int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30,
1612
int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40,
1613
int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50,
1614
int i51, int i52, int i53, int i54, int i55, int i56, int i57, int i58, int i59, int i60,
1615
int i61, int i62, int i63, int i64, int i65, int i66, int i67, int i68, int i69, int i70,
1616
int i71, int i72, int i73, int i74, int i75, int i76, int i77, int i78, int i79, int i80,
1617
int i81, int i82, int i83, int i84, int i85, int i86, int i87, int i88, int i89, int i90,
1618
int i91, int i92, int i93, int i94, int i95, int i96, int i97, int i98, int i99, int i100,
1619
int i101, int i102, int i103, int i104, int i105, int i106, int i107, int i108, int i109, int i110,
1620
int i111, int i112, int i113, int i114, int i115, int i116, int i117, int i118, int i119, int i120,
1621
int i121, int i122, int i123, int i124, int i125, int i126, int i127, int i128, int i129, int i130,
1622
int i131, int i132, int i133, int i134, int i135, int i136, int i137, int i138, int i139, int i140,
1623
int i141, int i142, int i143, int i144, int i145, int i146, int i147, int i148, int i149, int i150,
1624
int i151, int i152, int i153, int i154, int i155, int i156, int i157, int i158, int i159, int i160,
1625
int i161, int i162, int i163, int i164, int i165, int i166, int i167, int i168, int i169, int i170,
1626
int i171, int i172, int i173, int i174, int i175, int i176, int i177, int i178, int i179, int i180,
1627
int i181, int i182, int i183, int i184, int i185, int i186, int i187, int i188, int i189, int i190,
1628
int i191, int i192, int i193, int i194, int i195, int i196, int i197, int i198, int i199, int i200,
1629
int i201, int i202, int i203, int i204, int i205, int i206, int i207, int i208, int i209, int i210,
1630
int i211, int i212, int i213, int i214, int i215, int i216, int i217, int i218, int i219, int i220,
1631
int i221, int i222, int i223, int i224, int i225, int i226, int i227, int i228, int i229, int i230,
1632
int i231, int i232, int i233, int i234, int i235, int i236, int i237, int i238, int i239, int i240,
1633
int i241, int i242, int i243, int i244, int i245, int i246, int i247, int i248, int i249, int i250,
1634
int i251, int i252, int i253) {}
1635
private void helperSpreaderMethod_254arg(
1636
int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
1637
int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20,
1638
int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30,
1639
int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40,
1640
int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50,
1641
int i51, int i52, int i53, int i54, int i55, int i56, int i57, int i58, int i59, int i60,
1642
int i61, int i62, int i63, int i64, int i65, int i66, int i67, int i68, int i69, int i70,
1643
int i71, int i72, int i73, int i74, int i75, int i76, int i77, int i78, int i79, int i80,
1644
int i81, int i82, int i83, int i84, int i85, int i86, int i87, int i88, int i89, int i90,
1645
int i91, int i92, int i93, int i94, int i95, int i96, int i97, int i98, int i99, int i100,
1646
int i101, int i102, int i103, int i104, int i105, int i106, int i107, int i108, int i109, int i110,
1647
int i111, int i112, int i113, int i114, int i115, int i116, int i117, int i118, int i119, int i120,
1648
int i121, int i122, int i123, int i124, int i125, int i126, int i127, int i128, int i129, int i130,
1649
int i131, int i132, int i133, int i134, int i135, int i136, int i137, int i138, int i139, int i140,
1650
int i141, int i142, int i143, int i144, int i145, int i146, int i147, int i148, int i149, int i150,
1651
int i151, int i152, int i153, int i154, int i155, int i156, int i157, int i158, int i159, int i160,
1652
int i161, int i162, int i163, int i164, int i165, int i166, int i167, int i168, int i169, int i170,
1653
int i171, int i172, int i173, int i174, int i175, int i176, int i177, int i178, int i179, int i180,
1654
int i181, int i182, int i183, int i184, int i185, int i186, int i187, int i188, int i189, int i190,
1655
int i191, int i192, int i193, int i194, int i195, int i196, int i197, int i198, int i199, int i200,
1656
int i201, int i202, int i203, int i204, int i205, int i206, int i207, int i208, int i209, int i210,
1657
int i211, int i212, int i213, int i214, int i215, int i216, int i217, int i218, int i219, int i220,
1658
int i221, int i222, int i223, int i224, int i225, int i226, int i227, int i228, int i229, int i230,
1659
int i231, int i232, int i233, int i234, int i235, int i236, int i237, int i238, int i239, int i240,
1660
int i241, int i242, int i243, int i244, int i245, int i246, int i247, int i248, int i249, int i250,
1661
int i251, int i252, int i253, int i254) {}
1662
1663
private static void helperSpreaderStaticMethod_253arg(
1664
int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
1665
int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20,
1666
int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30,
1667
int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40,
1668
int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50,
1669
int i51, int i52, int i53, int i54, int i55, int i56, int i57, int i58, int i59, int i60,
1670
int i61, int i62, int i63, int i64, int i65, int i66, int i67, int i68, int i69, int i70,
1671
int i71, int i72, int i73, int i74, int i75, int i76, int i77, int i78, int i79, int i80,
1672
int i81, int i82, int i83, int i84, int i85, int i86, int i87, int i88, int i89, int i90,
1673
int i91, int i92, int i93, int i94, int i95, int i96, int i97, int i98, int i99, int i100,
1674
int i101, int i102, int i103, int i104, int i105, int i106, int i107, int i108, int i109, int i110,
1675
int i111, int i112, int i113, int i114, int i115, int i116, int i117, int i118, int i119, int i120,
1676
int i121, int i122, int i123, int i124, int i125, int i126, int i127, int i128, int i129, int i130,
1677
int i131, int i132, int i133, int i134, int i135, int i136, int i137, int i138, int i139, int i140,
1678
int i141, int i142, int i143, int i144, int i145, int i146, int i147, int i148, int i149, int i150,
1679
int i151, int i152, int i153, int i154, int i155, int i156, int i157, int i158, int i159, int i160,
1680
int i161, int i162, int i163, int i164, int i165, int i166, int i167, int i168, int i169, int i170,
1681
int i171, int i172, int i173, int i174, int i175, int i176, int i177, int i178, int i179, int i180,
1682
int i181, int i182, int i183, int i184, int i185, int i186, int i187, int i188, int i189, int i190,
1683
int i191, int i192, int i193, int i194, int i195, int i196, int i197, int i198, int i199, int i200,
1684
int i201, int i202, int i203, int i204, int i205, int i206, int i207, int i208, int i209, int i210,
1685
int i211, int i212, int i213, int i214, int i215, int i216, int i217, int i218, int i219, int i220,
1686
int i221, int i222, int i223, int i224, int i225, int i226, int i227, int i228, int i229, int i230,
1687
int i231, int i232, int i233, int i234, int i235, int i236, int i237, int i238, int i239, int i240,
1688
int i241, int i242, int i243, int i244, int i245, int i246, int i247, int i248, int i249, int i250,
1689
int i251, int i252, int i253) {}
1690
private static void helperSpreaderStaticMethod_254arg(
1691
int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
1692
int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20,
1693
int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30,
1694
int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40,
1695
int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50,
1696
int i51, int i52, int i53, int i54, int i55, int i56, int i57, int i58, int i59, int i60,
1697
int i61, int i62, int i63, int i64, int i65, int i66, int i67, int i68, int i69, int i70,
1698
int i71, int i72, int i73, int i74, int i75, int i76, int i77, int i78, int i79, int i80,
1699
int i81, int i82, int i83, int i84, int i85, int i86, int i87, int i88, int i89, int i90,
1700
int i91, int i92, int i93, int i94, int i95, int i96, int i97, int i98, int i99, int i100,
1701
int i101, int i102, int i103, int i104, int i105, int i106, int i107, int i108, int i109, int i110,
1702
int i111, int i112, int i113, int i114, int i115, int i116, int i117, int i118, int i119, int i120,
1703
int i121, int i122, int i123, int i124, int i125, int i126, int i127, int i128, int i129, int i130,
1704
int i131, int i132, int i133, int i134, int i135, int i136, int i137, int i138, int i139, int i140,
1705
int i141, int i142, int i143, int i144, int i145, int i146, int i147, int i148, int i149, int i150,
1706
int i151, int i152, int i153, int i154, int i155, int i156, int i157, int i158, int i159, int i160,
1707
int i161, int i162, int i163, int i164, int i165, int i166, int i167, int i168, int i169, int i170,
1708
int i171, int i172, int i173, int i174, int i175, int i176, int i177, int i178, int i179, int i180,
1709
int i181, int i182, int i183, int i184, int i185, int i186, int i187, int i188, int i189, int i190,
1710
int i191, int i192, int i193, int i194, int i195, int i196, int i197, int i198, int i199, int i200,
1711
int i201, int i202, int i203, int i204, int i205, int i206, int i207, int i208, int i209, int i210,
1712
int i211, int i212, int i213, int i214, int i215, int i216, int i217, int i218, int i219, int i220,
1713
int i221, int i222, int i223, int i224, int i225, int i226, int i227, int i228, int i229, int i230,
1714
int i231, int i232, int i233, int i234, int i235, int i236, int i237, int i238, int i239, int i240,
1715
int i241, int i242, int i243, int i244, int i245, int i246, int i247, int i248, int i249, int i250,
1716
int i251, int i252, int i253, int i254) {}
1717
private static void helperSpreaderStaticMethod_255arg(
1718
int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
1719
int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20,
1720
int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30,
1721
int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40,
1722
int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50,
1723
int i51, int i52, int i53, int i54, int i55, int i56, int i57, int i58, int i59, int i60,
1724
int i61, int i62, int i63, int i64, int i65, int i66, int i67, int i68, int i69, int i70,
1725
int i71, int i72, int i73, int i74, int i75, int i76, int i77, int i78, int i79, int i80,
1726
int i81, int i82, int i83, int i84, int i85, int i86, int i87, int i88, int i89, int i90,
1727
int i91, int i92, int i93, int i94, int i95, int i96, int i97, int i98, int i99, int i100,
1728
int i101, int i102, int i103, int i104, int i105, int i106, int i107, int i108, int i109, int i110,
1729
int i111, int i112, int i113, int i114, int i115, int i116, int i117, int i118, int i119, int i120,
1730
int i121, int i122, int i123, int i124, int i125, int i126, int i127, int i128, int i129, int i130,
1731
int i131, int i132, int i133, int i134, int i135, int i136, int i137, int i138, int i139, int i140,
1732
int i141, int i142, int i143, int i144, int i145, int i146, int i147, int i148, int i149, int i150,
1733
int i151, int i152, int i153, int i154, int i155, int i156, int i157, int i158, int i159, int i160,
1734
int i161, int i162, int i163, int i164, int i165, int i166, int i167, int i168, int i169, int i170,
1735
int i171, int i172, int i173, int i174, int i175, int i176, int i177, int i178, int i179, int i180,
1736
int i181, int i182, int i183, int i184, int i185, int i186, int i187, int i188, int i189, int i190,
1737
int i191, int i192, int i193, int i194, int i195, int i196, int i197, int i198, int i199, int i200,
1738
int i201, int i202, int i203, int i204, int i205, int i206, int i207, int i208, int i209, int i210,
1739
int i211, int i212, int i213, int i214, int i215, int i216, int i217, int i218, int i219, int i220,
1740
int i221, int i222, int i223, int i224, int i225, int i226, int i227, int i228, int i229, int i230,
1741
int i231, int i232, int i233, int i234, int i235, int i236, int i237, int i238, int i239, int i240,
1742
int i241, int i242, int i243, int i244, int i245, int i246, int i247, int i248, int i249, int i250,
1743
int i251, int i252, int i253, int i254, int i255) {}
1744
private void helperCollectorMethod(int[] i) {}
1745
private static void helperStaticCollectorMethod(int[] i) {}
1746
private void helperVarArgsMethod(String s, int... i) {}
1747
}
1748
1749
class HelperConstructorClass {
1750
public HelperConstructorClass(
1751
int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
1752
int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20,
1753
int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30,
1754
int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40,
1755
int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50,
1756
int i51, int i52, int i53, int i54, int i55, int i56, int i57, int i58, int i59, int i60,
1757
int i61, int i62, int i63, int i64, int i65, int i66, int i67, int i68, int i69, int i70,
1758
int i71, int i72, int i73, int i74, int i75, int i76, int i77, int i78, int i79, int i80,
1759
int i81, int i82, int i83, int i84, int i85, int i86, int i87, int i88, int i89, int i90,
1760
int i91, int i92, int i93, int i94, int i95, int i96, int i97, int i98, int i99, int i100,
1761
int i101, int i102, int i103, int i104, int i105, int i106, int i107, int i108, int i109, int i110,
1762
int i111, int i112, int i113, int i114, int i115, int i116, int i117, int i118, int i119, int i120,
1763
int i121, int i122, int i123, int i124, int i125, int i126, int i127, int i128, int i129, int i130,
1764
int i131, int i132, int i133, int i134, int i135, int i136, int i137, int i138, int i139, int i140,
1765
int i141, int i142, int i143, int i144, int i145, int i146, int i147, int i148, int i149, int i150,
1766
int i151, int i152, int i153, int i154, int i155, int i156, int i157, int i158, int i159, int i160,
1767
int i161, int i162, int i163, int i164, int i165, int i166, int i167, int i168, int i169, int i170,
1768
int i171, int i172, int i173, int i174, int i175, int i176, int i177, int i178, int i179, int i180,
1769
int i181, int i182, int i183, int i184, int i185, int i186, int i187, int i188, int i189, int i190,
1770
int i191, int i192, int i193, int i194, int i195, int i196, int i197, int i198, int i199, int i200,
1771
int i201, int i202, int i203, int i204, int i205, int i206, int i207, int i208, int i209, int i210,
1772
int i211, int i212, int i213, int i214, int i215, int i216, int i217, int i218, int i219, int i220,
1773
int i221, int i222, int i223, int i224, int i225, int i226, int i227, int i228, int i229, int i230,
1774
int i231, int i232, int i233, int i234, int i235, int i236, int i237, int i238, int i239, int i240,
1775
int i241, int i242, int i243, int i244, int i245, int i246, int i247, int i248, int i249, int i250,
1776
int i251, int i252, int i253) {}
1777
1778
public HelperConstructorClass(
1779
int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
1780
int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20,
1781
int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30,
1782
int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40,
1783
int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50,
1784
int i51, int i52, int i53, int i54, int i55, int i56, int i57, int i58, int i59, int i60,
1785
int i61, int i62, int i63, int i64, int i65, int i66, int i67, int i68, int i69, int i70,
1786
int i71, int i72, int i73, int i74, int i75, int i76, int i77, int i78, int i79, int i80,
1787
int i81, int i82, int i83, int i84, int i85, int i86, int i87, int i88, int i89, int i90,
1788
int i91, int i92, int i93, int i94, int i95, int i96, int i97, int i98, int i99, int i100,
1789
int i101, int i102, int i103, int i104, int i105, int i106, int i107, int i108, int i109, int i110,
1790
int i111, int i112, int i113, int i114, int i115, int i116, int i117, int i118, int i119, int i120,
1791
int i121, int i122, int i123, int i124, int i125, int i126, int i127, int i128, int i129, int i130,
1792
int i131, int i132, int i133, int i134, int i135, int i136, int i137, int i138, int i139, int i140,
1793
int i141, int i142, int i143, int i144, int i145, int i146, int i147, int i148, int i149, int i150,
1794
int i151, int i152, int i153, int i154, int i155, int i156, int i157, int i158, int i159, int i160,
1795
int i161, int i162, int i163, int i164, int i165, int i166, int i167, int i168, int i169, int i170,
1796
int i171, int i172, int i173, int i174, int i175, int i176, int i177, int i178, int i179, int i180,
1797
int i181, int i182, int i183, int i184, int i185, int i186, int i187, int i188, int i189, int i190,
1798
int i191, int i192, int i193, int i194, int i195, int i196, int i197, int i198, int i199, int i200,
1799
int i201, int i202, int i203, int i204, int i205, int i206, int i207, int i208, int i209, int i210,
1800
int i211, int i212, int i213, int i214, int i215, int i216, int i217, int i218, int i219, int i220,
1801
int i221, int i222, int i223, int i224, int i225, int i226, int i227, int i228, int i229, int i230,
1802
int i231, int i232, int i233, int i234, int i235, int i236, int i237, int i238, int i239, int i240,
1803
int i241, int i242, int i243, int i244, int i245, int i246, int i247, int i248, int i249, int i250,
1804
int i251, int i252, int i253, int i254) {}
1805
}
1806
1807