please include function callOpt_cached. static O call_cached(O o, S method, O... args) ctex { if (o == null) null; if (o instanceof Class) { Class c = (Class) o; _MethodCache cache = callOpt_getCache(c); // TODO: (super-rare) case where method exists static and non-static // with different args Method me = cache.findMethod(method, args); if (me == null) 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) fail("Method " + c.getName() + "." + method + "(" + joinWithComma(classNames(args)) + ") not found"); ret invokeMethod(me, o, args); } }