static final HashMap callMC_cache = new HashMap; static S callMC_key; static Method callMC_value; // varargs assignment fixer for a single string array argument static Object callMC(S method, S[] arg) { ret callMC(method, new O[] {arg}); } static O callMC(S method, O... args) ctex { Method me; synchronized(callMC_cache) { me = method == callMC_key ? callMC_value : null; } if (me != null) ret callMC_value.invoke(null, args); Method[] m; synchronized(callMC_cache) { m = callMC_cache.get(method); } if (m == null) { if (callMC_cache.isEmpty()) { callMC_makeCache(); m = callMC_cache.get(method); } if (m == null) fail("Method named " + method + " not found in main"); } int n = m.length; if (n == 1) { me = m[0]; synchronized(callMC_cache) { callMC_key = method; callMC_value = me; } ret me.invoke(null, args); } for i to n: { me = m[i]; if (call_checkArgs(me, args, false)) ret me.invoke(null, args); } fail("No method called " + method + " with matching arguments found in main"); } static void callMC_makeCache() { synchronized(callMC_cache) { callMC_cache.clear(); Class _c = (Class) mc(), c = _c; while (c != null) { for (Method m : c.getDeclaredMethods()) if ((m.getModifiers() & Modifier.STATIC) != 0 && !reflection_isForbiddenMethod(m)) { m.setAccessible(true); multiMapPut_array(callMC_cache, m.getName(), m); } c = c.getSuperclass(); } } }