code: public Object callMethod(Object o, String methodName, Object... args)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
  
      Method method = null;
      
      if (args == null || args.length == 0) {
        method = o.getClass().getDeclaredMethod(methodName);
      } else {
        Class<?>[] types = new Class[args.length];
        for (int i = 0; i < args.length; i++) {
          types[i] = args[i].getClass();
        }
        try {
          method = o.getClass().getDeclaredMethod(methodName, types);
        } catch (NoSuchMethodException e) {
          // Try more complex comparison for matching args to supertypes in the params
          method = findSupertypeMethod(o, methodName, types);
        }
      }
      
      if (method == null) {
        throw new NoSuchMethodException("Found no method named" + methodName + " with matching params");
      }
      
      method.setAccessible(true);
      
      return method.invoke(o, args);
    }
docs: Calls the specified method on the Object o with the specified arguments. Returns the
  result as an Object. Only methods declared on the class for Object o can be called.
  <p>
  The length of the vararg list of arguments to be passed to the method must match
  what the method expects. If no arguments are expected, null can be passed. If one
  argument is expected, that argument can be passed as an object. If multiple
  arguments are expected, they can be passed as an Object array or as a comma-separated
  list.
  
  @param o Object to access
  @param methodName Name of method to call
  @param args Vararg list of arguments to pass to method
  @return Object that is the result of calling the named method
  @throws NoSuchMethodException if the name or arguments don't match any declared method
  @throws IllegalAccessException
  @throws InvocationTargetException if some unexpected error occurs when invoking a method that was thought to match
  @throws IllegalArgumentException if the argument count doesn't match any method that has the same name