Executes a method of any Object by Java reflection.

@param o
an Object
@param methodName
name of the method
@param arg
a Double
@return the result of the method called
330288
public static <E> E send(Object o, String methodName, Double arg) {
    return send(o, methodName, (Object) arg);
  }
1030291
public static <T> T invokeMethodByName(final Object obj, final String methodName, final Object[] args) {
		Method method = getAccessibleMethodByName(obj.getClass(), methodName);
		if (method == null) {
			throw new IllegalArgumentException(
					"Could not find method [" + methodName + "] on class [" + obj.getClass() + ']');
		}
		return invokeMethod(obj, method, args);
	}
411580
public static <E> E send(Object o, String methodName, Short arg) {
    return send(o, methodName, (Object) arg);
  }
1291701
public Object invokeMethod(String name, Object args) {
        try {
            return super.invokeMethod(name, args);
        }
        // if the method was not found in the current scope (the script's methods)
        // let's try to see if there's a method closure with the same name in the binding
        catch (MissingMethodException mme) {
            try {
                if (name.equals(mme.getMethod())) {
                    Object boundClosure = getProperty(name);
                    if (boundClosure != null && boundClosure instanceof Closure) {
                        return ((Closure) boundClosure).call((Object[])args);
                    } else {
                        throw mme;
                    }
                } else {
                    throw mme;
                }
            } catch (MissingPropertyException mpe) {
                throw mme;
            }
        }
    }
543440
public <R> R execute(MailChimpMethod<R> method) throws IOException, MailChimpException {
		final Gson gson = MailChimpGsonFactory.createGson();

		JsonElement result = execute(buildUrl(method), gson.toJsonTree(method), method.getMetaInfo().version());
		if(result.isJsonObject()) {
			JsonElement error = result.getAsJsonObject().get("error");		
			if(error != null) {
				JsonElement code = result.getAsJsonObject().get("code");
				throw new MailChimpException(code.getAsInt(), error.getAsString());
			}
		}
		
		return gson.fromJson(result, method.getResultType());
	}
1021664
@SuppressWarnings("unchecked")
    public static <E> List<E> invoke(final Iterable<E> iterable, final String methodName,
                                  final List<Object> args) {
        final List<E> result = newArrayList();
        final List<Class<?>> argTypes = map(args, new Function<Object, Class<?>>() {
            public Class<?> apply(Object input) {
                return input.getClass();
            }
        });
        try {
            final Method method = iterable.iterator().next().getClass().getMethod(methodName, argTypes.toArray(
                new Class[argTypes.size()]));
            for (E arg : iterable) {
                try {
                    result.add((E) method.invoke(arg, args.toArray(new Object[args.size()])));
                } catch (Exception e) {
                    throw new IllegalArgumentException(e);
                }
            }
        } catch (NoSuchMethodException e) {
            throw new IllegalArgumentException(e);
        }
        return result;
    }
350583
public static <T> T invoke(String className, String methodName, Object[] args) {
		return invoke(className, methodName, false, args);
	}
862945
public Object invokeMethod(final String name, final Object args) {
        return this.wrapped.invokeMethod(name, args);
    }
805044
public static <E> E send(Object o, String methodName, Long arg) {
    return send(o, methodName, (Object) arg);
  }
111914
public Method findMethod (String methodName, Object[] args)
        throws NoSuchMethodException
    {
        return findMethod(methodName, ClassUtil.getParameterTypesFrom(args));
    }
210057
protected Object doInvokeMethod(String methodName, Object name, Object args) {
        super.doInvokeMethod(methodName, name, args);


        // return the completed node
        return lastCompletedNode;
    }
1324452
public static Object invokeObjectMethod(
            Object object, String methodName, Object[] args,
            Interpreter interpreter, CallStack callstack,
            SimpleNode callerInfo ) throws ReflectError, EvalError,
            InvocationTargetException {
        // Bsh scripted object
        if ( object instanceof This && !This.isExposedThisMethod(methodName) )
            return ((This)object).invokeMethod(
                methodName, args, interpreter, callstack, callerInfo,
                false/*delcaredOnly*/);

        // Plain Java object, find the java method
        try {
            BshClassManager bcm =
                interpreter == null ? null : interpreter.getClassManager();
            Class<?> clas = object.getClass();

            Invocable method = resolveExpectedJavaMethod(
                bcm, clas, object, methodName, args, false );
            NameSpace ns = getThisNS(object);
            if (null != ns)
                ns.setNode(callerInfo);
            return method.invoke(object, args);
        } catch ( UtilEvalError e ) {
            throw e.toEvalError( callerInfo, callstack );
        }
    }
124449
public static <T> T invokeMethod(final Object obj, Method method, Object... args) {
		try {
			return (T) method.invoke(obj, args);
		} catch (Exception e) {
			throw ExceptionUtil.unwrapAndUnchecked(e);
		}
	}
928812
public static void callProc(Object instance, Class<?> type, String methodName, Class<?>[] types, Object... args) {
		try {
			final Method method = type.getDeclaredMethod(methodName, types);
			method.setAccessible(true);
			method.invoke(instance, args);
		} catch (Exception exception) {
			throw new Error(exception);
		}
	}
1374643
public static <T> T invokeMethod(final Object obj, final String methodName, final Object[] args,
			final Class<?>[] parameterTypes) {
		Method method = getMethod(obj.getClass(), methodName, parameterTypes);
		if (method == null) {
			throw new IllegalArgumentException("Could not find method [" + methodName + "] with parameter types:"
					+ ObjectUtil.toPrettyString(parameterTypes) + " on class [" + obj.getClass() + ']');
		}
		return invokeMethod(obj, method, args);
	}
314513
@SuppressWarnings("unchecked")
    public static <T> T performMethodInvocation(Object tested, Method methodToInvoke, Object... arguments)
            throws Exception {
        final boolean accessible = methodToInvoke.isAccessible();
        if (!accessible) {
            methodToInvoke.setAccessible(true);
        }
        try {
            if (isPotentialVarArgsMethod(methodToInvoke, arguments)) {
                Class<?>[] parameterTypes = methodToInvoke.getParameterTypes();
                final int varArgsIndex = parameterTypes.length - 1;
                Class<?> varArgsType = parameterTypes[varArgsIndex].getComponentType();
                Object varArgsArrayInstance = createAndPopulateVarArgsArray(varArgsType, varArgsIndex, arguments);
                Object[] completeArgumentList = new Object[parameterTypes.length];
                System.arraycopy(arguments, 0, completeArgumentList, 0, varArgsIndex);
                completeArgumentList[completeArgumentList.length - 1] = varArgsArrayInstance;
                return (T) methodToInvoke.invoke(tested, completeArgumentList);
            } else {
                return (T) methodToInvoke.invoke(tested, arguments == null ? new Object[]{arguments} : arguments);
            }
        } catch (InvocationTargetException e) {
            Throwable cause = e.getCause();
            if (cause instanceof Exception) {
                throw (Exception) cause;
            } else if (cause instanceof Error) {
                throw (Error) cause;
            } else {
                throw new MethodInvocationException(cause);
            }
        } finally {
            if (!accessible) {
                methodToInvoke.setAccessible(false);
            }
        }
    }
321160
public static Object invokeMethod(Object target, String method, Object... args) {
    try {
      return InvokerHelper.invokeMethod(target, method, args);
    } catch (InvokerInvocationException e) {
      ExceptionUtil.sneakyThrow(e.getCause());
      return null; // never reached
    }
  }