code: public static Method getMostSpecificMethod(Method method, Class<?> targetClass) {
  
          if (method != null && isOverridable(method, targetClass) && targetClass != null
                  && targetClass != method.getDeclaringClass()) {
              try {
                  try {
                      return targetClass.getMethod(method.getName(), method.getParameterTypes());
                  } catch (NoSuchMethodException ex) {
                      return method;
                  }
              } catch (SecurityException ex) {
              }
          }
          return method;
      }
docs: Given a method, which may come from an interface, and a target class used in the current reflective invocation, find the
  corresponding target method if there is one. E.g. the method may be {@code IFoo.bar()} and the target class may be
  {@code DefaultFoo}. In this case, the method may be {@code DefaultFoo.bar()}. This enables attributes on that method to
  be found.
  
  @param method the method to be invoked, which may come from an interface
  @param targetClass the target class for the current invocation. May be {@code null} or may not even implement the method.
  @return the specific target method, or the original method if the {@code targetClass} doesn't implement it or is
  {@code null}