static int allParametersAndArgumentsMatchWithDefaultParams(Parameter[] params,ClassNode[] args){
  int dist=0;
  ClassNode ptype=null;
  for (int i=0, j=0; i < params.length; i++) {
    Parameter param=params[i];
    ClassNode paramType=param.getType();
    ClassNode arg=j >= args.length ? null : args[j];
    if (arg == null || !isAssignableTo(arg,paramType)) {
      if (!param.hasInitialExpression() && (ptype == null || !ptype.equals(paramType))) {
        return -1;
      }
      ptype=null;
    }
 else {
      j++;
      if (!paramType.equals(arg))       dist+=getDistance(arg,paramType);
      if (param.hasInitialExpression()) {
        ptype=arg;
      }
 else {
        ptype=null;
      }
    }
  }
  return dist;
}

static int allParametersAndArgumentsMatchWithDefaultParams ( Parameter [ ] params , ClassNode [ ] args ) { int dist = 0 ; ClassNode ptype = null ; for ( int i = 0 , j = 0 ; i < params . length ; i ++ ) { Parameter param = params [ i ] ; ClassNode paramType = param . getType ( ) ; ClassNode arg = j >= args . length ? null : args [ j ] ; if ( arg == null || ! isAssignableTo ( arg , paramType ) ) { if ( ! param . hasInitialExpression ( ) && ( ptype == null || ! ptype . equals ( paramType ) ) ) { return - 1 ; } ptype = null ; } else { j ++ ; if ( ! paramType . equals ( arg ) ) dist += getDistance ( arg , paramType ) ; if ( param . hasInitialExpression ( ) ) { ptype = arg ; } else { ptype = null ; } } } return dist ; }
checks that arguments and parameter types match , expecting that the number of parameters is strictly greater than the number of arguments , allowing possible inclusion of default parameters .
