paulk-asert commented on code in PR #2018: URL: https://github.com/apache/groovy/pull/2018#discussion_r1434931626
########## src/main/java/org/codehaus/groovy/reflection/CachedClass.java: ########## @@ -282,14 +274,36 @@ public CachedMethod searchMethods(String name, CachedClass[] parameterTypes) { CachedMethod res = null; for (CachedMethod m : methods) { if (m.getName().equals(name) - && ReflectionCache.arrayContentsEq(parameterTypes, m.getParameterTypes()) + && arrayContentsEq(parameterTypes, m.getParameterTypes()) && (res == null || res.getReturnType().isAssignableFrom(m.getReturnType()))) res = m; } return res; } + private static boolean arrayContentsEq(Object[] a1, Object[] a2) { + if (a1 == null) { + return a2 == null || a2.length == 0; + } + + if (a2 == null) { + return a1.length == 0; + } + + if (a1.length != a2.length) { + return false; + } + + for (int i = 0; i < a1.length; i++) { + if (a1[i] != a2[i]) { + return false; + } + } + + return true; + } Review Comment: Arrays.equals would be less code to maintain but is likely less efficient. I'm inclined to leave as is for now. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org