code: public Method createMethod(C object, String methodName, Class[] parameterTypes) throws NoSuchMethodException {
          Class clazz = object.getClass();
  
          try {
              @SuppressWarnings("unchecked")
              Method method = clazz.getMethod(methodName, parameterTypes);
              return method;
  
          } catch (NoSuchMethodException nsme) {
              String info = "The specified class " + clazz.getName();
              info += " does not have a method \"" + methodName + "\" as expected: ";
              info += nsme.getMessage();
              throw new NoSuchMethodException(info);
          }
      }
docs: Creates a method for a class.
  @param object the object to which the method belongs.
  @param methodName name of method.
  @param parameterTypes an array of parameter types for the method.
  @throws NoSuchMethodException if method is not found on object.