code: public static <T> T invoke(Object target, Method method, Object[] arguments, Class<T> returnType) {
      try {
        boolean currentAccessible = method.isAccessible();
        method.setAccessible(true);
        Object returnValue = method.invoke(target, arguments);
        method.setAccessible(currentAccessible);
        return returnType.cast(returnValue);
      }
      catch (NullPointerException e) {
        throw e;
      }
      catch (Exception e) {
        throw new MethodInvocationException(String.format("Failed to invoke method (%1$s) on %2$s type (%3$s)!",
          getMethodSignature(method), BooleanUtils.toString(target == null, "class", "object of"),
            method.getDeclaringClass().getName()), e);
      }
    }
docs: Calls the method with the specified name on the given object, passing the given arguments and casting
  the method's return value to the desired class type.  If the target object is null, then this method assumes
  the "method" to invoke is a static (class) member method, otherwise the "method" to invoke is considered
  an instance (object) member method.
  
  @param <T> the desired return type in which the method's return value will be cast; should be compatible with
  the method's return type.
  @param target the Object on which the method is defined and will be invoked.
  @param method the Method to invoke.
  @param arguments an array of objects constituting the method's signature as well as the arguments
  to the method's parameters.
  @param returnType the desired Class type in which to cast the method's return value.
  @return the specified method's return value cast to the desired return type.
  @throws MethodInvocationException if the method invocation (call) fails to be executed successfully.
  @throws NullPointerException if the method or returnType parameter arguments are null.
  @see #getMethodSignature(String, Class[], Class)
  @see java.lang.reflect.Method#invoke(Object, Object...)
  @see java.lang.reflect.Method#setAccessible(boolean)