final sclass MethodCache { final Class c; final HashMap> cache = new HashMap; *(Class *c) { init(); } synchronized init() { cache.clear(); Class _c = c; while (_c != null) { for (Method m : _c.getDeclaredMethods()) if ((m.getModifiers() & java.lang.reflect.Modifier.STATIC) != 0) { m.setAccessible(true); multiMapPut(cache, m.getName(), m); } _c = _c.getSuperclass(); } } // If there is a matching method, it finds it // If there is not, might return one with same name but bad args static O findMethod(S method, O[] args) ctex { L m; synchronized(this) { m = callMC_cache.get(method); if (m == null) { if (callMC_cache.isEmpty()) { init(); m = callMC_cache.get(method); } if (m == null) fail("Method named " + method + " not found in main"); } } int n = m.size(); if (n == 1) ret m.get(0); for i to n: { Method me = m.get(i); if (call_checkArgs(me, args, false)) ret me; } null; } }