please include function callOpt_cached. static O call_withVarargs(O o, S method, O... args) ctex { if (o == null) null; if (o instanceof Class) { Class c = (Class) o; _MethodCache cache = callOpt_getCache(c); Method me = cache.findMethod(method, args); if (me == null) { // TODO: varargs fail("Method " + c.getName() + "." + method + "(" + joinWithComma(classNames(args)) + ") not found"); } if ((me.getModifiers() & Modifier.STATIC) == 0) fail("Method " + c.getName() + "." + method + "(" + joinWithComma(classNames(args)) + ") not static"); ret invokeMethod(me, null, args); } else { Class c = o.getClass(); _MethodCache cache = callOpt_getCache(c); Method me = cache.findMethod(method, args); if (me != null) ret invokeMethod(me, o, args); // try varargs L methods = cache.cache.get(method); if (methods != null) methodSearch: for (Method m : methods) { continue unless m.isVarArgs(); Class[] types = m.getParameterTypes(); int n = types.length-1, nArgs = args.length; continue unless nArgs >= n; for i to n: if (!argumentCompatibleWithType(arg, types[i])) continue methodSearch; Class varArgType = types[n].getComponentType(); for (int i = n; i < nArgs; i++) if (!argumentCompatibleWithType(arg, varArgType)) continue methodSearch; O[] newArgs = new O[n+1]; arrayCopy(args, 0, newArgs, 0, n); O[] varArgs = arrayOfType(varArgType, nArgs-n); arrayCopy(args, n, varArgs, 0, nArgs-n); newArgs[n] = varArgs; ret invokeMethod(me, o, newArgs); } } findVarargsMethodInCache(cache, method, args); fail("Method " + c.getName() + "." + method + "(" + joinWithComma(classNames(args)) + ") not found"); } }