}
}
}
// Second pass: look for method where arguments can be converted to parameter types.
TypeConverter converter = getTypeConverter();
if (converter != null) {
for (int i = 0; i < candidates.length; i++) {
if (candidates[i].getName().equals(getTargetMethod())) {
// Check if the inspected method has the correct number of parameters.
Class[] paramTypes = candidates[i].getParameterTypes();
if (paramTypes.length == argCount) {
Object[] argumentsToUse = new Object[argCount];
int numberOfCorrectArguments = 0;
for (int j = 0; j < argCount; j++) {
// Verify that the supplied argument is assignable to the method parameter.
try {
argumentsToUse[j] = converter.convertIfNecessary(arguments[j], paramTypes[j]);
numberOfCorrectArguments++;
}
catch (TypeMismatchException ex) {
// Ignore -> simply doesn't match.
}