Source:
private static Method getMethod0(Class<?> clazz, String methodName, Class<?>[] paramTypes, Object[] params) { Method matchingMethod = null; if (paramTypes != null) { try { matchingMethod = Util.getMethod(clazz, clazz.getMethod(methodName, paramTypes)); } catch (NoSuchMethodException e) { int paramCount = 0; if (params != null) { paramCount = params.length; } Method[] methods = clazz.getMethods(); for (Method m : methods) { if (methodName.equals(m.getName())) { if (m.getParameterTypes().length == paramCount) { matchingMethod = Util.getMethod(clazz, m); break; } if (m.isVarArgs() && paramCount > m.getParameterTypes().length - 2) { matchingMethod = Util.getMethod(clazz, m); } } } if (matchingMethod == null) { throw new MethodNotFoundException("Unable to find method [" + methodName + "] with [" + paramCount + "] parameters"); } } } else { int paramCount = 0; if (params != null) { paramCount = params.length; } Method[] methods = clazz.getMethods(); for (Method m : methods) { if (methodName.equals(m.getName())) { if (m.getParameterTypes().length == paramCount) { matchingMethod = Util.getMethod(clazz, m); break; } if (m.isVarArgs() && paramCount > m.getParameterTypes().length - 2) { matchingMethod = Util.getMethod(clazz, m); } } } if (matchingMethod == null) { throw new MethodNotFoundException("Unable to find method [" + methodName + "] with [" + paramCount + "] parameters"); } } if (matchingMethod != null) { Map<CachedMethodInfo, Method> clzMap = METHODS_CACHE.get(clazz); if (clzMap == null) { clzMap = new ConcurrentHashMap<>(); METHODS_CACHE.put(clazz, clzMap); } clzMap.put(new CachedMethodInfo(methodName, paramTypes), matchingMethod); } return matchingMethod; }

Target:
private static Method getMethod0(Class<?> clazz, String methodName, Class<?>[] paramTypes, Object[] params) { Method matchingMethod = null; if (paramTypes != null) { try { matchingMethod = Util.getMethod(clazz, clazz.getMethod(methodName, paramTypes)); } catch (NoSuchMethodException e) { int paramCount = 0; if (params != null) { paramCount = params.length; } Method[] methods = clazz.getMethods(); for (Method m : methods) { if (methodName.equals(m.getName())) { if (m.getParameterTypes().length == paramCount) { matchingMethod = Util.getMethod(clazz, m); break; } if (m.isVarArgs() && paramCount > m.getParameterTypes().length - 2) { matchingMethod = Util.getMethod(clazz, m); } } } if (matchingMethod == null) { throw new MethodNotFoundException("Unable to find method [" + methodName + "] with [" + paramCount + "] parameters"); } } } else { int paramCount = 0; if (params != null) { paramCount = params.length; } Method[] methods = clazz.getMethods(); for (Method m : methods) { if (methodName.equals(m.getName())) { if (m.getParameterTypes().length == paramCount) { matchingMethod = Util.getMethod(clazz, m); break; } if (m.isVarArgs() && paramCount > m.getParameterTypes().length - 2) { matchingMethod = Util.getMethod(clazz, m); } } } if (matchingMethod == null) { throw new MethodNotFoundException("Unable to find method [" + methodName + "] with [" + paramCount + "] parameters"); } } if (matchingMethod != null) METHODS_CACHE.computeIfAbsent(clazz, k -> new ConcurrentHashMap<>()) .put(new CachedMethodInfo(methodName, paramTypes), matchingMethod); return matchingMethod; }