code: public static Method getMethod(Class<?> type, String methodName, Class<?>... parameterTypes) {
          Class<?> thisType = type;
          if (parameterTypes == null) {
              parameterTypes = new Class<?>[0];
          }
          while (thisType != null) {
              Method[] methodsToTraverse = null;
              if (thisType.isInterface()) {
                  // Interfaces only contain public (and abstract) methods, no
                  // need to traverse the hierarchy.
                  methodsToTraverse = getAllPublicMethods(thisType);
              } else {
                  methodsToTraverse = thisType.getDeclaredMethods();
              }
              for (Method method : methodsToTraverse) {
                  if (methodName.equals(method.getName())
                              && checkIfParameterTypesAreSame(method.isVarArgs(), parameterTypes, method.getParameterTypes())) {
                      method.setAccessible(true);
                      return method;
                  }
              }
              thisType = thisType.getSuperclass();
          }
  
          throwExceptionIfMethodWasNotFound(type, methodName, null, new Object[]{parameterTypes});
          return null;
      }
docs: Convenience method to get a method from a class type without having to
  catch the checked exceptions otherwise required. These exceptions are
  wrapped as runtime exceptions.
  
  The method will first try to look for a declared method in the same
  class. If the method is not declared in this class it will look for the
  method in the super class. This will continue throughout the whole class
  hierarchy. If the method is not found an {@link IllegalArgumentException}
  is thrown.
  
  @param type           The type of the class where the method is located.
  @param methodName     The method names.
  @param parameterTypes All parameter types of the method (may be {@code null}).
  @return A .