static final new ConcurrentHashMap getMethodCache_chm; static _MethodCache getMethodCache_chm(Class c) { _MethodCache cache = getMethodCache_chm.get(c); if (cache == null) getMethodCache_chm.put(c, cache = _MethodCache(c)); ret cache; } // This one gets ~44 mill/s cache lookups which is definitely better than the old method svoid bench_concurrentHashMapBasedMethodCache() { print("Loading 1000 classes"); L classes = map classForName(takeFirst(1000, classNamesInJigsawModule("java.base"))); print("Have " + nClasses(classes) + ". Filling method caches"); time { for (c : classes) assertNotNull(getMethodCache_chm(c)); } print("Looking them up again."); benchFor5(-> { for (c : classes) assertNotNull(getMethodCache_chm(c)); }); print("Classes in method cache: " + l(getMethodCache_chm)); }