// immutable, has strong refs final sclass _MethodCache { final Class c; final HashMap> cache = new HashMap; *(Class *c) { _init(); } void _init() { Class _c = c; while (_c != null) { for (Method m : _c.getDeclaredMethods()) { m.setAccessible(true); multiMapPut(cache, m.getName(), m); } _c = _c.getSuperclass(); } ifdef _MethodCache_debug print("MethodCache " + this + ": " + className(c) + " => " + keys(cache)); endifdef } // Returns only matching methods Method findMethod(S method, O[] args) ctex { L m = cache.get(method); ifdef _MethodCache_debug print("findMethod " + this + ": " + className(c) + "/" + method + " => " + m); endifdef if (m == null) null; int n = m.size(); for i to n: { Method me = m.get(i); if (call_checkArgs(me, args, false)) ret me; } null; } }