Lines Matching defs:nargs

250     static Object[] randomArgs(int nargs, Class<?> param) {
251 Object[] args = new Object[nargs];
342 static MethodHandle addTrailingArgs(MethodHandle target, int nargs, Class<?> argClass) {
344 int extra = (nargs - targetLen);
1668 for (int nargs = 0; nargs < 50; nargs++) {
1669 if (CAN_TEST_LIGHTLY && nargs > 11) break;
1670 for (int pos = 0; pos <= nargs; pos++) {
1671 if (CAN_TEST_LIGHTLY && pos > 2 && pos < nargs-2) continue;
1672 if (nargs > 10 && pos > 4 && pos < nargs-4 && pos % 10 != 3)
1674 testSpreadArguments(argType, pos, nargs);
1679 public void testSpreadArguments(Class<?> argType, int pos, int nargs) throws Throwable {
1682 MethodHandle target2 = varargsArray(arrayType, nargs);
1685 System.out.println("spread into "+target2+" ["+pos+".."+nargs+"]");
1688 if (pos == 0 && nargs < 5 && !argType.isPrimitive()) {
1691 switch (nargs) {
1708 List<Class<?>> spreadParams = newParams.subList(pos, nargs);
1712 MethodHandle result = target2.asSpreader(arrayType, nargs-pos);
1762 for (int nargs = 0; nargs < 50; nargs++) {
1763 if (CAN_TEST_LIGHTLY && nargs > 11) break;
1764 for (int pos = 0; pos <= nargs; pos++) {
1765 if (CAN_TEST_LIGHTLY && pos > 2 && pos < nargs-2) continue;
1766 if (nargs > 10 && pos > 4 && pos < nargs-4 && pos % 10 != 3)
1768 testCollectArguments(argType, pos, nargs);
1773 public void testCollectArguments(Class<?> argType, int pos, int nargs) throws Throwable {
1776 MethodHandle fake = varargsArray(nargs);
1788 System.out.println("collect from "+Arrays.asList(args)+" ["+pos+".."+nargs+"]");
1789 MethodHandle result = target.asCollector(Object[].class, nargs-pos).asType(newType);
1801 for (int nargs = 0; nargs < 50; nargs++) {
1802 if (CAN_TEST_LIGHTLY && nargs > 11) break;
1803 for (int ins = 0; ins <= nargs; ins++) {
1804 if (nargs > 10 && ins > 4 && ins < nargs-4 && ins % 10 != 3)
1806 for (int pos = 0; pos <= nargs; pos++) {
1807 if (nargs > 10 && pos > 4 && pos < nargs-4 && pos % 10 != 3)
1809 if (CAN_TEST_LIGHTLY && pos > 2 && pos < nargs-2) continue;
1810 testInsertArguments(nargs, pos, ins);
1816 void testInsertArguments(int nargs, int pos, int ins) throws Throwable {
1818 MethodHandle target = varargsArray(nargs + ins);
1834 // System.out.println("*** fail at n/p/i = "+nargs+"/"+pos+"/"+ins+": "+resList+" => "+res2List);
1844 for (int nargs = 0; nargs <= 3; nargs++) {
1852 testFilterReturnValue(nargs, rtype);
1857 void testFilterReturnValue(int nargs, Class<?> rtype) throws Throwable {
1859 MethodHandle target = varargsList(nargs, rtype);
1866 Object[] argsToPass = randomArgs(nargs, Object.class);
1883 System.out.println("*** fail at n/rt = "+nargs+"/"+rtype.getSimpleName()+": "+Arrays.asList(argsToPass)+" => "+result+" != "+expected);
1891 for (int nargs = 1; nargs <= 6; nargs++) {
1892 for (int pos = 0; pos < nargs; pos++) {
1893 testFilterArguments(nargs, pos);
1898 void testFilterArguments(int nargs, int pos) throws Throwable {
1900 MethodHandle target = varargsList(nargs);
1903 Object[] argsToPass = randomArgs(nargs, Object.class);
1915 System.out.println("*** fail at n/p = "+nargs+"/"+pos+": "+Arrays.asList(argsToPass)+" => "+result+" != "+expected);
1923 for (int nargs = 0; nargs <= 4; nargs++) {
1924 for (int fold = 0; fold <= nargs; fold++) {
1925 for (int pos = 0; pos <= nargs; pos++) {
1926 testFoldArguments(nargs, pos, fold);
1932 void testFoldArguments(int nargs, int pos, int fold) throws Throwable {
1935 MethodHandle target = varargsList(1 + nargs);
1937 List<Object> argsToPass = Arrays.asList(randomArgs(nargs, Object.class));
1952 System.out.println("*** fail at n/p/f = "+nargs+"/"+pos+"/"+fold+": "+argsToPass+" => "+result+" != "+expected);
1960 for (int nargs = 0; nargs <= 4; nargs++) {
1962 for (int pos = 0; pos <= nargs; pos++) {
1963 testDropArguments(nargs, pos, drop);
1969 void testDropArguments(int nargs, int pos, int drop) throws Throwable {
1971 MethodHandle target = varargsArray(nargs);
1983 // System.out.println("*** fail at n/p/d = "+nargs+"/"+pos+"/"+drop+": "+argsToDrop+" => "+res2List);
2018 int nargs = type.parameterCount();
2043 if (nargs <= 3 && type == type.generic()) {
2045 switch (nargs) {
2078 if (nargs >= 1 && type == type.generic()) {
2082 result = inv.invokeExact(target, args[0], Arrays.copyOfRange(args, 1, nargs));
2086 if (nargs >= 2 && type == type.generic()) {
2090 result = inv.invokeExact(target, args[0], args[1], Arrays.copyOfRange(args, 2, nargs));
2094 if (nargs >= 3 && type == type.generic()) {
2098 result = inv.invokeExact(target, args[0], args[1], args[2], Arrays.copyOfRange(args, 3, nargs));
2102 for (int k = 0; k <= nargs; k++) {
2104 if (CAN_TEST_LIGHTLY && (k > 1 || k < nargs - 1)) continue;
2108 MethodType expType = (type.dropParameterTypes(k, nargs)
2113 List<Object> tailList = targetPlusVarArgs.subList(1+k, 1+nargs);
2184 for (int nargs = 0; nargs <= 50; nargs++) {
2185 if (CAN_TEST_LIGHTLY && nargs > 7) break;
2186 testGuardWithTest(nargs, Object.class);
2187 testGuardWithTest(nargs, String.class);
2190 void testGuardWithTest(int nargs, Class<?> argClass) throws Throwable {
2191 testGuardWithTest(nargs, 0, argClass);
2192 if (nargs <= 5 || nargs % 10 == 3) {
2193 for (int testDrops = 1; testDrops <= nargs; testDrops++)
2194 testGuardWithTest(nargs, testDrops, argClass);
2197 void testGuardWithTest(int nargs, int testDrops, Class<?> argClass) throws Throwable {
2199 int nargs1 = Math.min(3, nargs);
2203 while (test.type().parameterCount() > nargs)
2212 int testArgs = nargs - testDrops;
2214 test = addTrailingArgs(test, Math.min(testArgs, nargs), argClass);
2215 target = addTrailingArgs(target, nargs, argClass);
2216 fallback = addTrailingArgs(fallback, nargs, argClass);
2225 if (argList.length != nargs) {
2227 argList1 = Arrays.copyOf(argList, nargs);
2228 Arrays.fill(argList1, nargs1, nargs, MISSING_ARG_2);
2238 switch (nargs) {
2255 for (int nargs = 0; nargs < 40; nargs++) {
2256 if (CAN_TEST_LIGHTLY && nargs > 11) break;
2258 testCatchException(int.class, new ClassCastException("testing"), throwMode, nargs);
2259 if (CAN_TEST_LIGHTLY && nargs > 3) continue;
2260 testCatchException(void.class, new java.io.IOException("testing"), throwMode, nargs);
2261 testCatchException(String.class, new LinkageError("testing"), throwMode, nargs);
2268 void testCatchException(Class<?> returnType, Throwable thrown, int throwMode, int nargs) throws Throwable {
2269 testCatchException(returnType, thrown, throwMode, nargs, 0);
2270 if (nargs <= 5 || nargs % 10 == 3) {
2271 for (int catchDrops = 1; catchDrops <= nargs; catchDrops++)
2272 testCatchException(returnType, thrown, throwMode, nargs, catchDrops);
2292 void testCatchException(Class<?> returnType, Throwable thrown, int throwMode, int nargs, int catchDrops) throws Throwable {
2295 System.out.println("catchException rt="+returnType+" throw="+throwMode+" nargs="+nargs+" drops="+catchDrops);
2308 int nargs1 = Math.max(2, nargs);
2310 thrower = addTrailingArgs(thrower, nargs, Object.class);
2311 int catchArgc = 1 + nargs - catchDrops;
2313 Object[] args = randomArgs(nargs, Object.class);
2316 if (nargs > 0) arg0 = args[0];
2317 if (nargs > 1) args[1] = arg1;
2319 if (nargs < nargs1) {
2321 appendArgs = Arrays.copyOfRange(appendArgs, nargs, nargs1);
2322 thrower = MethodHandles.insertArguments(thrower, nargs, appendArgs);
2324 assertEquals(nargs, thrower.type().parameterCount());
2327 assertEquals(nargs, target.type().parameterCount());
2345 catchArgs.subList(nargs - catchDrops, nargs).clear();
2872 int nargs = arrays.size();
2873 MethodType type = MethodType.genericMethodType(nargs).changeReturnType(Object[].class);
2892 public static MethodHandle varargsArray(int nargs) {
2893 if (nargs < ARRAYS.length)
2894 return ARRAYS[nargs];
2895 return MethodHandles.identity(Object[].class).asCollector(Object[].class, nargs);
2897 public static MethodHandle varargsArray(Class<?> arrayType, int nargs) {
2899 MethodType vaType = MethodType.methodType(arrayType, Collections.<Class<?>>nCopies(nargs, elemType));
2900 MethodHandle mh = varargsArray(nargs);
2961 int nargs = lists.size();
2962 MethodType type = MethodType.genericMethodType(nargs).changeReturnType(List.class);
2987 public static MethodHandle varargsList(int nargs) {
2988 if (nargs < LISTS.length)
2989 return LISTS[nargs];
2990 return AS_LIST.asCollector(Object[].class, nargs);