private void resolveGeneral() throws NameResolutionException {
    Method[] allMethods = _targetClass.getMethods();
    // keep only ones whose method names match and have the same number of args
    List<Method> candidates = new ArrayList<>();
    for (Method meth : allMethods) {
      /*
       * if (Modifier.isStatic(meth.getModifiers())) continue;
       */
      if (!meth.getName().equals(_methodName)) {
        continue;
      }
      if (meth.getParameterTypes().length != _argTypes.length) {
        continue;
      }
      // are the args all convertible to the parameter types?
      if (!TypeUtils.areTypesConvertible(_argTypes, meth.getParameterTypes())) {
        continue;
      }
      candidates.add(meth);
    }

    if (candidates.isEmpty()) {
      throw new NameNotFoundException(
          String.format(
              "No applicable and accessible method named ' %s ' was found in class ' %s ' for the argument types %s",
              _methodName, _targetClass.getName(), Arrays.asList(_argTypes)));
    }

    // now we have a list of accessible and applicable method,
    // choose the most specific
    if (candidates.size() == 1) {
      _method = candidates.get(0);
      return;
    }

    sortByDecreasingSpecificity(candidates);
    // get the first two methods in the sorted list,
    // if they are equally specific, then throw AmbiguousMethodException
    Method meth1 = candidates.get(0);
    Method meth2 = candidates.get(1);
    // if meth1 cannot be type-converted to meth2, then meth1 is not more
    // specific than meth2 and the invocation is ambiguous.
    // special case a null argument type in this case, since there should
    // be not differentiation for those parameter types regarding specificity

    if (equalSpecificity(meth1, meth2, _argTypes)) {
      throw new AmbiguousNameException(
          String.format(
              "Two or more maximally specific methods were found for the method named ' %s ' in class ' %s ' for the argument types: %s",
              meth1.getName(), _targetClass.getName(), Arrays.asList(_argTypes)));
    }

    _method = meth1;
  }
Utility class for mapping operations in the query language to Java methods
geode-core/src/main/java/org/apache/geode/cache/query/internal/MethodDispatch.java