blob: 161a0c8b6feb662b5fbbd9bd1e41c90fedbda2fa [file] [log] [blame]
jrose25aef892010-10-30 21:02:30 -07001/*
jmelvin75479992012-04-16 18:09:53 -04002 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
jrose25aef892010-10-30 21:02:30 -07003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
serb9adafbe2013-11-12 20:24:25 +04007 * published by the Free Software Foundation.
jrose25aef892010-10-30 21:02:30 -07008 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/* @test
jrose79e0a6c2011-05-12 19:27:33 -070025 * @summary unit tests for java.lang.invoke.MethodHandle.invoke
alanb499341f2011-09-10 14:55:14 +010026 * @compile InvokeGenericTest.java
henryjenf6613f42013-08-12 12:11:04 -070027 * @run testng/othervm test.java.lang.invoke.InvokeGenericTest
jrose25aef892010-10-30 21:02:30 -070028 */
29
jroseada69fa2011-03-23 23:02:31 -070030package test.java.lang.invoke;
jrose25aef892010-10-30 21:02:30 -070031
jroseada69fa2011-03-23 23:02:31 -070032import java.lang.invoke.*;
33import static java.lang.invoke.MethodHandles.*;
34import static java.lang.invoke.MethodType.*;
jrose25aef892010-10-30 21:02:30 -070035import java.lang.reflect.*;
36import java.util.*;
henryjenf6613f42013-08-12 12:11:04 -070037import org.testng.*;
38import static org.testng.AssertJUnit.*;
39import org.testng.annotations.*;
jrose25aef892010-10-30 21:02:30 -070040
41/**
42 *
43 * @author jrose
44 */
jrose49494522012-01-18 17:34:29 -080045@SuppressWarnings("cast") // various casts help emphasize arguments to invokeExact
jrose25aef892010-10-30 21:02:30 -070046public class InvokeGenericTest {
47 // How much output?
48 static int verbosity = 0;
49 static {
jroseada69fa2011-03-23 23:02:31 -070050 String vstr = System.getProperty("test.java.lang.invoke.InvokeGenericTest.verbosity");
jrose25aef892010-10-30 21:02:30 -070051 if (vstr != null) verbosity = Integer.parseInt(vstr);
52 }
53
jrosebb3eb372011-05-17 19:48:14 -070054// public static void main(String... av) throws Throwable {
55// new InvokeGenericTest().testFirst();
56// }
jrose320b7692011-05-12 19:27:49 -070057
jrose25aef892010-10-30 21:02:30 -070058 @Test
59 public void testFirst() throws Throwable {
60 verbosity += 9; try {
61 // left blank for debugging
62 } finally { printCounts(); verbosity -= 9; }
63 }
64
65 public InvokeGenericTest() {
66 }
67
jrose25aef892010-10-30 21:02:30 -070068 String testName;
69 static int allPosTests, allNegTests;
70 int posTests, negTests;
henryjenf6613f42013-08-12 12:11:04 -070071 @AfterMethod
jrose25aef892010-10-30 21:02:30 -070072 public void printCounts() {
73 if (verbosity >= 2 && (posTests | negTests) != 0) {
74 System.out.println();
75 if (posTests != 0) System.out.println("=== "+testName+": "+posTests+" positive test cases run");
76 if (negTests != 0) System.out.println("=== "+testName+": "+negTests+" negative test cases run");
77 allPosTests += posTests;
78 allNegTests += negTests;
79 posTests = negTests = 0;
80 }
81 }
82 void countTest(boolean positive) {
83 if (positive) ++posTests;
84 else ++negTests;
85 }
86 void countTest() { countTest(true); }
87 void startTest(String name) {
88 if (testName != null) printCounts();
89 if (verbosity >= 1)
jrose320b7692011-05-12 19:27:49 -070090 System.out.println("["+name+"]");
jrose25aef892010-10-30 21:02:30 -070091 posTests = negTests = 0;
92 testName = name;
93 }
94
95 @BeforeClass
96 public static void setUpClass() throws Exception {
97 calledLog.clear();
98 calledLog.add(null);
99 nextArgVal = INITIAL_ARG_VAL;
100 }
101
102 @AfterClass
103 public static void tearDownClass() throws Exception {
104 int posTests = allPosTests, negTests = allNegTests;
105 if (verbosity >= 2 && (posTests | negTests) != 0) {
106 System.out.println();
107 if (posTests != 0) System.out.println("=== "+posTests+" total positive test cases");
108 if (negTests != 0) System.out.println("=== "+negTests+" total negative test cases");
109 }
110 }
111
jrose49494522012-01-18 17:34:29 -0800112 static List<Object> calledLog = new ArrayList<>();
jrose25aef892010-10-30 21:02:30 -0700113 static Object logEntry(String name, Object... args) {
114 return Arrays.asList(name, Arrays.asList(args));
115 }
116 static Object called(String name, Object... args) {
117 Object entry = logEntry(name, args);
118 calledLog.add(entry);
119 return entry;
120 }
121 static void assertCalled(String name, Object... args) {
122 Object expected = logEntry(name, args);
123 Object actual = calledLog.get(calledLog.size() - 1);
124 if (expected.equals(actual) && verbosity < 9) return;
125 System.out.println("assertCalled "+name+":");
126 System.out.println("expected: "+expected);
127 System.out.println("actual: "+actual);
128 System.out.println("ex. types: "+getClasses(expected));
129 System.out.println("act. types: "+getClasses(actual));
130 assertEquals("previous method call", expected, actual);
131 }
132 static void printCalled(MethodHandle target, String name, Object... args) {
133 if (verbosity >= 3)
134 System.out.println("calling MH="+target+" to "+name+Arrays.toString(args));
135 }
136
137 static Object castToWrapper(Object value, Class<?> dst) {
138 Object wrap = null;
139 if (value instanceof Number)
140 wrap = castToWrapperOrNull(((Number)value).longValue(), dst);
141 if (value instanceof Character)
142 wrap = castToWrapperOrNull((char)(Character)value, dst);
143 if (wrap != null) return wrap;
144 return dst.cast(value);
145 }
146
147 static Object castToWrapperOrNull(long value, Class<?> dst) {
148 if (dst == int.class || dst == Integer.class)
149 return (int)(value);
150 if (dst == long.class || dst == Long.class)
151 return (long)(value);
152 if (dst == char.class || dst == Character.class)
153 return (char)(value);
154 if (dst == short.class || dst == Short.class)
155 return (short)(value);
156 if (dst == float.class || dst == Float.class)
157 return (float)(value);
158 if (dst == double.class || dst == Double.class)
159 return (double)(value);
160 if (dst == byte.class || dst == Byte.class)
161 return (byte)(value);
162 if (dst == boolean.class || dst == boolean.class)
163 return ((value % 29) & 1) == 0;
164 return null;
165 }
166
167 static final int ONE_MILLION = (1000*1000), // first int value
168 TEN_BILLION = (10*1000*1000*1000), // scale factor to reach upper 32 bits
169 INITIAL_ARG_VAL = ONE_MILLION << 1; // <<1 makes space for sign bit;
170 static long nextArgVal;
171 static long nextArg(boolean moreBits) {
172 long val = nextArgVal++;
173 long sign = -(val & 1); // alternate signs
174 val >>= 1;
175 if (moreBits)
176 // Guarantee some bits in the high word.
177 // In any case keep the decimal representation simple-looking,
178 // with lots of zeroes, so as not to make the printed decimal
179 // strings unnecessarily noisy.
180 val += (val % ONE_MILLION) * TEN_BILLION;
181 return val ^ sign;
182 }
183 static int nextArg() {
184 // Produce a 32-bit result something like ONE_MILLION+(smallint).
185 // Example: 1_000_042.
186 return (int) nextArg(false);
187 }
188 static long nextArg(Class<?> kind) {
189 if (kind == long.class || kind == Long.class ||
190 kind == double.class || kind == Double.class)
191 // produce a 64-bit result something like
192 // ((TEN_BILLION+1) * (ONE_MILLION+(smallint)))
193 // Example: 10_000_420_001_000_042.
194 return nextArg(true);
195 return (long) nextArg();
196 }
197
198 static Object randomArg(Class<?> param) {
199 Object wrap = castToWrapperOrNull(nextArg(param), param);
200 if (wrap != null) {
201 return wrap;
202 }
jroseada69fa2011-03-23 23:02:31 -0700203// import sun.invoke.util.Wrapper;
jrose25aef892010-10-30 21:02:30 -0700204// Wrapper wrap = Wrapper.forBasicType(dst);
205// if (wrap == Wrapper.OBJECT && Wrapper.isWrapperType(dst))
206// wrap = Wrapper.forWrapperType(dst);
207// if (wrap != Wrapper.OBJECT)
208// return wrap.wrap(nextArg++);
209 if (param.isInterface()) {
210 for (Class<?> c : param.getClasses()) {
211 if (param.isAssignableFrom(c) && !c.isInterface())
212 { param = c; break; }
213 }
214 }
215 if (param.isInterface() || param.isAssignableFrom(String.class))
216 return "#"+nextArg();
217 else
218 try {
219 return param.newInstance();
jrose49494522012-01-18 17:34:29 -0800220 } catch (InstantiationException | IllegalAccessException ex) {
jrose25aef892010-10-30 21:02:30 -0700221 }
222 return null; // random class not Object, String, Integer, etc.
223 }
224 static Object[] randomArgs(Class<?>... params) {
225 Object[] args = new Object[params.length];
226 for (int i = 0; i < args.length; i++)
227 args[i] = randomArg(params[i]);
228 return args;
229 }
230 static Object[] randomArgs(int nargs, Class<?> param) {
231 Object[] args = new Object[nargs];
232 for (int i = 0; i < args.length; i++)
233 args[i] = randomArg(param);
234 return args;
235 }
236
237 static final Object ANON_OBJ = new Object();
238 static Object zeroArg(Class<?> param) {
239 Object x = castToWrapperOrNull(0L, param);
240 if (x != null) return x;
241 if (param.isInterface() || param.isAssignableFrom(String.class)) return "\"\"";
242 if (param == Object.class) return ANON_OBJ;
243 if (param.getComponentType() != null) return Array.newInstance(param.getComponentType(), 0);
244 return null;
245 }
246 static Object[] zeroArgs(Class<?>... params) {
247 Object[] args = new Object[params.length];
248 for (int i = 0; i < args.length; i++)
249 args[i] = zeroArg(params[i]);
250 return args;
251 }
252 static Object[] zeroArgs(List<Class<?>> params) {
253 return zeroArgs(params.toArray(new Class<?>[0]));
254 }
255
jrose49494522012-01-18 17:34:29 -0800256 @SafeVarargs @SuppressWarnings("varargs")
jrose25aef892010-10-30 21:02:30 -0700257 static <T, E extends T> T[] array(Class<T[]> atype, E... a) {
258 return Arrays.copyOf(a, a.length, atype);
259 }
jrose49494522012-01-18 17:34:29 -0800260 @SafeVarargs @SuppressWarnings("varargs")
jrose25aef892010-10-30 21:02:30 -0700261 static <T> T[] cat(T[] a, T... b) {
262 int alen = a.length, blen = b.length;
263 if (blen == 0) return a;
264 T[] c = Arrays.copyOf(a, alen + blen);
265 System.arraycopy(b, 0, c, alen, blen);
266 return c;
267 }
268 static Integer[] boxAll(int... vx) {
269 Integer[] res = new Integer[vx.length];
270 for (int i = 0; i < res.length; i++) {
271 res[i] = vx[i];
272 }
273 return res;
274 }
275 static Object getClasses(Object x) {
276 if (x == null) return x;
277 if (x instanceof String) return x; // keep the name
278 if (x instanceof List) {
279 // recursively report classes of the list elements
280 Object[] xa = ((List)x).toArray();
281 for (int i = 0; i < xa.length; i++)
282 xa[i] = getClasses(xa[i]);
283 return Arrays.asList(xa);
284 }
285 return x.getClass().getSimpleName();
286 }
287
288 static MethodHandle changeArgTypes(MethodHandle target, Class<?> argType) {
289 return changeArgTypes(target, 0, 999, argType);
290 }
291 static MethodHandle changeArgTypes(MethodHandle target,
292 int beg, int end, Class<?> argType) {
293 MethodType targetType = target.type();
294 end = Math.min(end, targetType.parameterCount());
jrose49494522012-01-18 17:34:29 -0800295 ArrayList<Class<?>> argTypes = new ArrayList<>(targetType.parameterList());
jrose25aef892010-10-30 21:02:30 -0700296 Collections.fill(argTypes.subList(beg, end), argType);
297 MethodType ttype2 = MethodType.methodType(targetType.returnType(), argTypes);
jrose9b82ad62011-05-26 17:37:36 -0700298 return target.asType(ttype2);
jrose25aef892010-10-30 21:02:30 -0700299 }
300
301 // This lookup is good for all members in and under InvokeGenericTest.
302 static final Lookup LOOKUP = MethodHandles.lookup();
303
jrose49494522012-01-18 17:34:29 -0800304 Map<List<Class<?>>, MethodHandle> CALLABLES = new HashMap<>();
jrose25aef892010-10-30 21:02:30 -0700305 MethodHandle callable(List<Class<?>> params) {
306 MethodHandle mh = CALLABLES.get(params);
307 if (mh == null) {
jroseadc650a2011-02-11 01:26:28 -0800308 mh = collector_MH.asType(methodType(Object.class, params));
jrose25aef892010-10-30 21:02:30 -0700309 CALLABLES.put(params, mh);
310 }
311 return mh;
312 }
313 MethodHandle callable(Class<?>... params) {
314 return callable(Arrays.asList(params));
315 }
316 private static Object collector(Object... args) {
317 return Arrays.asList(args);
318 }
319 private static final MethodHandle collector_MH;
320 static {
321 try {
322 collector_MH
323 = LOOKUP.findStatic(LOOKUP.lookupClass(),
324 "collector",
325 methodType(Object.class, Object[].class));
jrosef15905c2011-02-11 01:26:32 -0800326 } catch (ReflectiveOperationException ex) {
jrose25aef892010-10-30 21:02:30 -0700327 throw new RuntimeException(ex);
328 }
329 }
330
331 @Test
332 public void testSimple() throws Throwable {
333 startTest("testSimple");
334 countTest();
335 String[] args = { "one", "two" };
336 MethodHandle mh = callable(Object.class, String.class);
jrose49494522012-01-18 17:34:29 -0800337 Object res; List<?> resl;
338 res = resl = (List<?>) mh.invoke((String)args[0], (Object)args[1]);
jrose79e0a6c2011-05-12 19:27:33 -0700339 //System.out.println(res);
340 assertEquals(Arrays.asList(args), res);
341 }
342
343 @Test
jrose320b7692011-05-12 19:27:49 -0700344 public void testSimplePrims() throws Throwable {
345 startTest("testSimplePrims");
346 countTest();
347 int[] args = { 1, 2 };
348 MethodHandle mh = callable(Object.class, Object.class);
jrose49494522012-01-18 17:34:29 -0800349 Object res; List<?> resl;
350 res = resl = (List<?>) mh.invoke(args[0], args[1]);
jrose320b7692011-05-12 19:27:49 -0700351 //System.out.println(res);
352 assertEquals(Arrays.toString(args), res.toString());
353 }
354
355 @Test
jrose79e0a6c2011-05-12 19:27:33 -0700356 public void testAlternateName() throws Throwable {
357 startTest("testAlternateName");
358 countTest();
359 String[] args = { "one", "two" };
360 MethodHandle mh = callable(Object.class, String.class);
jrose49494522012-01-18 17:34:29 -0800361 Object res; List<?> resl;
362 res = resl = (List<?>) mh.invoke((String)args[0], (Object)args[1]);
jrose25aef892010-10-30 21:02:30 -0700363 //System.out.println(res);
364 assertEquals(Arrays.asList(args), res);
365 }
366
367 @Test
368 public void testWrongArgumentCount() throws Throwable {
369 startTest("testWrongArgumentCount");
370 for (int i = 0; i <= 10; i++) {
371 testWrongArgumentCount(Collections.<Class<?>>nCopies(i, Integer.class));
372 if (i <= 4) {
373 testWrongArgumentCount(Collections.<Class<?>>nCopies(i, int.class));
374 testWrongArgumentCount(Collections.<Class<?>>nCopies(i, long.class));
375 }
376 }
377 }
378 public void testWrongArgumentCount(List<Class<?>> params) throws Throwable {
379 int max = params.size();
380 for (int i = 0; i < max; i++) {
381 List<Class<?>> params2 = params.subList(0, i);
382 for (int k = 0; k <= 2; k++) {
383 if (k == 1) params = methodType(Object.class, params).generic().parameterList();
384 if (k == 2) params2 = methodType(Object.class, params2).generic().parameterList();
385 testWrongArgumentCount(params, params2);
386 testWrongArgumentCount(params2, params);
387 }
388 }
389 }
390 public void testWrongArgumentCount(List<Class<?>> expect, List<Class<?>> observe) throws Throwable {
391 countTest(false);
392 if (expect.equals(observe))
393 assert(false);
394 MethodHandle target = callable(expect);
395 Object[] args = zeroArgs(observe);
396 Object junk;
397 try {
398 switch (args.length) {
399 case 0:
jrose79e0a6c2011-05-12 19:27:33 -0700400 junk = target.invoke(); break;
jrose25aef892010-10-30 21:02:30 -0700401 case 1:
jrose79e0a6c2011-05-12 19:27:33 -0700402 junk = target.invoke(args[0]); break;
jrose25aef892010-10-30 21:02:30 -0700403 case 2:
jrose79e0a6c2011-05-12 19:27:33 -0700404 junk = target.invoke(args[0], args[1]); break;
jrose25aef892010-10-30 21:02:30 -0700405 case 3:
jrose79e0a6c2011-05-12 19:27:33 -0700406 junk = target.invoke(args[0], args[1], args[2]); break;
jrose25aef892010-10-30 21:02:30 -0700407 case 4:
jrose79e0a6c2011-05-12 19:27:33 -0700408 junk = target.invoke(args[0], args[1], args[2], args[3]); break;
jrose25aef892010-10-30 21:02:30 -0700409 default:
jrose900bafd2010-10-30 21:08:23 -0700410 junk = target.invokeWithArguments(args); break;
jrose25aef892010-10-30 21:02:30 -0700411 }
412 } catch (WrongMethodTypeException ex) {
413 return;
414 } catch (Exception ex) {
jrose320b7692011-05-12 19:27:49 -0700415 throw new RuntimeException("wrong exception calling "+target+" on "+Arrays.asList(args), ex);
jrose25aef892010-10-30 21:02:30 -0700416 }
jrose320b7692011-05-12 19:27:49 -0700417 throw new RuntimeException("bad success calling "+target+" on "+Arrays.asList(args));
jrose25aef892010-10-30 21:02:30 -0700418 }
419
420 /** Make a list of all combinations of the given types, with the given arities.
421 * A void return type is possible iff the first type is void.class.
422 */
423 static List<MethodType> allMethodTypes(int minargc, int maxargc, Class<?>... types) {
jrose49494522012-01-18 17:34:29 -0800424 ArrayList<MethodType> result = new ArrayList<>();
jrose25aef892010-10-30 21:02:30 -0700425 if (types.length > 0) {
jrose49494522012-01-18 17:34:29 -0800426 ArrayList<MethodType> argcTypes = new ArrayList<>();
jrose25aef892010-10-30 21:02:30 -0700427 // build arity-zero types first
428 for (Class<?> rtype : types) {
429 argcTypes.add(MethodType.methodType(rtype));
430 }
431 if (types[0] == void.class)
432 // void is not an argument type
433 types = Arrays.copyOfRange(types, 1, types.length);
434 for (int argc = 0; argc <= maxargc; argc++) {
435 if (argc >= minargc)
436 result.addAll(argcTypes);
437 if (argc >= maxargc)
438 break;
439 ArrayList<MethodType> prevTypes = argcTypes;
jrose49494522012-01-18 17:34:29 -0800440 argcTypes = new ArrayList<>();
jrose25aef892010-10-30 21:02:30 -0700441 for (MethodType prevType : prevTypes) {
442 for (Class<?> ptype : types) {
443 argcTypes.add(prevType.insertParameterTypes(argc, ptype));
444 }
445 }
446 }
447 }
448 return Collections.unmodifiableList(result);
449 }
450 static List<MethodType> allMethodTypes(int argc, Class<?>... types) {
451 return allMethodTypes(argc, argc, types);
452 }
453
jrose25aef892010-10-30 21:02:30 -0700454 MethodHandle toString_MH;
455
456 @Test
457 public void testReferenceConversions() throws Throwable {
458 startTest("testReferenceConversions");
459 toString_MH = LOOKUP.
460 findVirtual(Object.class, "toString", MethodType.methodType(String.class));
jrose79e0a6c2011-05-12 19:27:33 -0700461 Object[] args = { "one", "two" };
jrosebb3eb372011-05-17 19:48:14 -0700462 for (MethodType type : allMethodTypes(2, Object.class, String.class, CharSequence.class)) {
jrose25aef892010-10-30 21:02:30 -0700463 testReferenceConversions(type, args);
464 }
465 }
466 public void testReferenceConversions(MethodType type, Object... args) throws Throwable {
467 countTest();
jrosebb3eb372011-05-17 19:48:14 -0700468 int nargs = args.length;
469 List<Object> argList = Arrays.asList(args);
470 String expectString = argList.toString();
471 if (verbosity > 3) System.out.println("target type: "+type+expectString);
jrose25aef892010-10-30 21:02:30 -0700472 MethodHandle mh = callable(type.parameterList());
jrosebb3eb372011-05-17 19:48:14 -0700473 mh = MethodHandles.filterReturnValue(mh, toString_MH);
jrose25aef892010-10-30 21:02:30 -0700474 mh = mh.asType(type);
jrosebb3eb372011-05-17 19:48:14 -0700475 Object res = null;
476 if (nargs == 2) {
477 res = mh.invoke((Object)args[0], (Object)args[1]);
478 assertEquals(expectString, res);
479 res = mh.invoke((String)args[0], (Object)args[1]);
480 assertEquals(expectString, res);
481 res = mh.invoke((Object)args[0], (String)args[1]);
482 assertEquals(expectString, res);
483 res = mh.invoke((String)args[0], (String)args[1]);
484 assertEquals(expectString, res);
485 res = mh.invoke((String)args[0], (CharSequence)args[1]);
486 assertEquals(expectString, res);
487 res = mh.invoke((CharSequence)args[0], (Object)args[1]);
488 assertEquals(expectString, res);
489 res = (String) mh.invoke((Object)args[0], (Object)args[1]);
490 assertEquals(expectString, res);
491 res = (String) mh.invoke((String)args[0], (Object)args[1]);
492 assertEquals(expectString, res);
493 res = (CharSequence) mh.invoke((String)args[0], (Object)args[1]);
494 assertEquals(expectString, res);
495 } else {
496 assert(false); // write this code
497 }
jrose25aef892010-10-30 21:02:30 -0700498 //System.out.println(res);
jrose25aef892010-10-30 21:02:30 -0700499 }
500
501
jrosebb3eb372011-05-17 19:48:14 -0700502 @Test
jrose25aef892010-10-30 21:02:30 -0700503 public void testBoxConversions() throws Throwable {
504 startTest("testBoxConversions");
505 countTest();
jrose79e0a6c2011-05-12 19:27:33 -0700506 Object[] args = { 1, 2 };
jrose25aef892010-10-30 21:02:30 -0700507 MethodHandle mh = callable(Object.class, int.class);
jrose49494522012-01-18 17:34:29 -0800508 Object res; List<?> resl; int resi;
509 res = resl = (List<?>) mh.invoke((int)args[0], (Object)args[1]);
jrose25aef892010-10-30 21:02:30 -0700510 //System.out.println(res);
511 assertEquals(Arrays.asList(args), res);
jrosebb3eb372011-05-17 19:48:14 -0700512 mh = MethodHandles.identity(int.class);
513 mh = MethodHandles.dropArguments(mh, 1, int.class);
514 res = resi = (int) mh.invoke((Object) args[0], (Object) args[1]);
515 assertEquals(args[0], res);
516 res = resi = (int) mh.invoke((int) args[0], (Object) args[1]);
517 assertEquals(args[0], res);
jrose25aef892010-10-30 21:02:30 -0700518 }
519
520}