Hi there, I discovered a bug in the class MethodUtils: when comparing method parameters to find a matching method the search is interrupted when method parameters don't match, but the non-matching method is still returned. When the first method returned by Java is appropriate this bug will go unnoticed; it was quite hard to track down...
I fixed it by breaking out of the compare loop and continue with the next method candidate as shown in the enclosed patch. greets, Klaasjan Brand
--- orig/MethodUtils.java Wed Apr 3 13:50:22 2002 +++ fix/MethodUtils.java Wed Apr 3 13:50:34 2002 @@ -504,7 +504,7 @@ // search through all methods int paramSize = parameterTypes.length; Method[] methods = clazz.getMethods(); - for (int i = 0, size = methods.length; i < size ; i++) { + outer: for (int i = 0, size = methods.length; i < size ; i++) { if (methods[i].getName().equals(methodName)) { // log some trace information if (log.isTraceEnabled()) { @@ -517,12 +517,12 @@ int methodParamSize = methodsParams.length; if (methodParamSize == paramSize) { for (int n = 0 ; n < methodParamSize; n++) { - if (!parameterTypes[n].isAssignableFrom(methodsParams[n])) { + if (!methodsParams[n].isAssignableFrom(parameterTypes[n])) { if (log.isTraceEnabled()) { log.trace(parameterTypes[n] + " is not assignable from " + methodsParams[n]); } - break; + continue outer; } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>