Wywołuje określoną metodę obiektu przekazując do niej dostarczone parametry.

@param target Obiekt, którego metoda ma zostać wywołana.
@param method Nazwa metody do wywołania.
@param args Tablica argumentów metody.
@return Obiekt zwracany przez metodę.
174777
public static Object invokeMethod(Object target, String method, Object... args) {
		Class<?>[] types = new Class[args.length];
		for(int index = args.length - 1; index >= 0; index--) {
			types[index] = args[index].getClass();
		}
		try {
			return target.getClass().getMethod(method, types).invoke(target, args);
		} catch(Throwable t) {
			throw new MethodInvocationException(t);
		}
	}
660953
public static boolean isVoidMethod(@Nullable Object target, String method, Object... args) {
    if (target == null) return false; // no way to tell

    Class[] argTypes = ReflectionUtil.getTypes(args);

    // the way we choose metaClass, we won't find methods on java.lang.Class
    // but since java.lang.Class has no void methods other than the ones inherited
    // from java.lang.Object, and since we operate on a best effort basis, that's OK
    // also we will choose a static method like Foo.getName() over the equally
    // named method on java.lang.Class, but this is consistent with current Groovy semantics
    // (see http://jira.codehaus.org/browse/GROOVY-3548)
    // in the end it's probably best to rely on NullAwareInvokeMethodSpec to tell us if
    // everything is OK
    MetaClass metaClass = target instanceof Class ?
        InvokerHelper.getMetaClass((Class) target) : InvokerHelper.getMetaClass(target);

    // seems to find more methods than getMetaMethod()
    MetaMethod metaMethod = metaClass.pickMethod(method, argTypes);
    if (metaMethod == null) return false; // we were unable to figure out which method was called

    Class returnType = metaMethod.getReturnType();
    // although Void.class will occur rarely, it makes sense to handle
    // it in the same way as void.class
    return returnType == void.class || returnType == Void.class;
  }
332810
private function search_pg_proc ($method, $args) {
    $argtypenames = array ();
    $argtypeschemas = array ();
    $nargs = count ($args);

    $query = "SELECT * FROM pgprocedures.search_function ('".$this->name."', '$method', $nargs)";
    
    $rettypename = null;

    if ($res = $this->pgproc_query ($query)) {
      if ($row = pg_fetch_array ($res)) {
	$schema = $row['proc_nspname'];
	$argtypes = $row['proargtypes'];
	$rettype = $row['prorettype'];

	// Get the arguments types
	$argtypeslist = explode (' ', $argtypes);
	foreach ($argtypeslist as $argtype) {
	  if (!strlen (trim ($argtype)))
	    continue;

	  list($argtypeschemas[], $argtypenames[]) = $this->get_pgtype_and_schema ($argtype);
	}

	if ((in_array($row['ret_typtype'], array('b', 'p', 'e')))) { // scalar type: (b)ase, (p)seudo-type, (e)num
	  $rettypename = $row['ret_typname'];
	  
	} else if ($row['ret_typtype'] == 'c') { // composite type
	  $query3 = "select attname, typname FROM pg_attribute INNER JOIN pg_type ON pg_attribute.atttypid = pg_type.oid WHERE pg_attribute.attrelid = (select oid FROM pg_class where relname = '".$row['ret_typname']."') AND attnum > 0 ORDER BY attnum";
	  if ($res3 = $this->pgproc_query ($query3)) {
	    $rettypename = array();
	    while ($row3 = pg_fetch_array ($res3)) {
	      $rettypename[$row3['attname']] =  $row3['typname'];
	    }
	  }
	}

      }
    }
    if (count ($argtypenames) == $nargs)
      return array ($schema, $argtypeschemas, $argtypenames, $row['ret_typtype'], $rettypename, ($row['proretset'] == 't'));
    else
      return NULL;
  }
64411
public Object invoke(Method method, Object[] args) throws Throwable {

        return MethodExecutionListenerUtils.invoke(new MethodExecutionListenerUtils.MethodExecutionCallback() {
            @Override
            public Object execute(Object proxyTarget, Method method, Object[] args) throws Throwable {
                return performQueryExecutionListener(method, args);
            }
        }, this.proxyConfig, this.statement, this.connectionInfo, method, args);

    }
363614
public final Invokable<T, Object> method(Method method) {
    checkArgument(of(method.getDeclaringClass()).isAssignableFrom(this),
        "%s not declared by %s", method, this);
    return new Invokable.MethodInvokable<T>(method) {
      @Override Type getGenericReturnType() {
        return resolveType(super.getGenericReturnType()).getType();
      }
      @Override Type[] getGenericParameterTypes() {
        return resolveInPlace(super.getGenericParameterTypes());
      }
      @Override Type[] getGenericExceptionTypes() {
        return resolveInPlace(super.getGenericExceptionTypes());
      }
      @Override public TypeToken<T> getOwnerType() {
        return TypeToken.this;
      }
      @Override public String toString() {
        return getOwnerType() + "." + super.toString();
      }
    };
  }
849510
public Object execute(Object[] arguments) throws Exception
	{
		try
		{
			if (this.method == null)
			{
				if (this.parameterTypes == null)
					this.parameterTypes = PROXY.toParameterTypes(arguments);

				this.method = PROXY.findMethod(this.targetClass,
						this.methodName, this.parameterTypes);
			}

			return this.method.invoke(target, arguments);
		}
		catch (IllegalArgumentException e)
		{
			throw new IllegalArgumentException(target.getClass().getName()+"."+this.method+"("+Debugger.toString(e)+")");
		}
		catch (NoSuchMethodException e)
		{
			throw e;
		}
		catch (IllegalAccessException e)
		{
			throw e;
		}
		catch (InvocationTargetException e)
		{
			if (e.getCause() instanceof Exception)
				throw (Exception) e.getCause();
			else
				throw e;
		}

	}
287631
public Statement apply(FrameworkMethod method, Description description, Object target,
            Statement statement) {
        if (methodRules.isEmpty() && testRules.isEmpty()) {
            return statement;
        }
        Statement result = statement;
        for (RuleEntry ruleEntry : getSortedEntries()) {
            if (ruleEntry.type == RuleEntry.TYPE_TEST_RULE) {
                result = ((TestRule) ruleEntry.rule).apply(result, description);
            } else {
                result = ((MethodRule) ruleEntry.rule).apply(result, method, target);
            }
        }
        return result;
    }
557024
private static Class<?> findTargetComponentType(final Method method) {
        final Class<?> returnType = method.getReturnType();
        if (returnType.isArray()) {
            return method.getReturnType().getComponentType();
        }

        if (!(List.class.equals(returnType) || (Map.class.equals(returnType)) || XBAutoMap.class.isAssignableFrom(returnType) || XBAutoList.class.equals(returnType) || XBAutoValue.class.equals(returnType) || ReflectionHelper.isStreamClass(returnType))) {
            return null;
        }
        final Type type = method.getGenericReturnType();
        if (!(type instanceof ParameterizedType) || (((ParameterizedType) type).getActualTypeArguments() == null) || (((ParameterizedType) type).getActualTypeArguments().length < 1)) {
            throw new IllegalArgumentException("When using List as return type for method " + method + ", please specify a generic type for the List. Otherwise I do not know which type I should fill the List with.");
        }
        int index = Map.class.equals(returnType) ? 1 : 0;

        assert index < ((ParameterizedType) type).getActualTypeArguments().length;
        Type componentType = ((ParameterizedType) type).getActualTypeArguments()[index];
        if (!(componentType instanceof Class)) {
            throw new IllegalArgumentException("I don't know how to instantiate the generic type for the return type of method " + method);
        }
        return (Class<?>) componentType;
    }
177796
public double getPValue(final String method) {
        double p = Double.NaN;

        if ("t".equals(method)) {
            double[] baselineValues = new double[baselineMetricPerDimension.values().size()];
            int i = 0;
            for (Double d : baselineMetricPerDimension.values()) {
                baselineValues[i] = d;
                i++;
            }

            double[] testValues = new double[testMetricPerDimension.values().size()];
            i = 0;
            for (Double d : testMetricPerDimension.values()) {
                testValues[i] = d;
                i++;
            }

            p = TestUtils.tTest(baselineValues, testValues);
        } else {
            double[] baselineValues = new double[dimensions.size()];
            int i = 0;
            for (Object d : dimensions) {
                baselineValues[i] = baselineMetricPerDimension.get(d);
                i++;
            }

            double[] testValues = new double[dimensions.size()];
            i = 0;
            for (Object d : dimensions) {
                testValues[i] = testMetricPerDimension.get(d);
                i++;
            }
            if ("pairedT".equals(method)) {
                p = TestUtils.pairedTTest(baselineValues, testValues);
            } else if ("wilcoxon".equals(method)) {
                p = new WilcoxonSignedRankTest().wilcoxonSignedRankTest(baselineValues, testValues, false);
            }
        }
        return p;
    }
934480
public static Method[] candidateMethods(Method[] methods, Object[] args) {
        return candidateMethods(methods, collectArgTypes(args));
    }
531260
private EJBMethodInfoImpl getEJBMethodInfo(Method method)
    {
        // Get target method signature.
        String targetSignature = MethodAttribUtils.methodSignature(method);

        // Search array of EJBMethodInfo object until the one that matches
        // target signature is found or all array elements are processed.
        EJBMethodInfoImpl minfo = null;
        int n = ivMdbMethods.length;
        for (int i = 0; i < n; ++i)
        {
            minfo = ivMdbMethods[i];
            if (targetSignature.equals(minfo.getMethodSignature()))
            {
                return minfo;
            }
        }

        // Method not found, so return null.
        return null;
    }
614442
protected static Method findTargetMethod(final Method sourceMethod, Class<?> target) throws NoSuchElementException {
        return Iterables.find(Arrays.asList(target.getMethods()), new Predicate<Method>() {
            @Override
            public boolean apply(Method element) {
                if (!sourceMethod.getName().equals(element.getName())) {
                    return false;
                }
                if (sourceMethod.getParameterTypes().length != element.getParameterTypes().length) {
                    return false;
                }
                return true;
            }
        });
    }
85973
public static MethodHandle findMethodHandle(Object target,String methodName,Object ...args)
	{
		Class<?>[] ptypes = new Class<?>[args.length];
		for(int i=0;i<args.length;i++)
		{
			ptypes[i]=args[i].getClass();
		}
		return findMethodHandle(target, methodName, ptypes);
	}
13637
public UiSelector call(String method, Object ... args) throws Exception {
        new QueryBuilder().retrieveResult(storedId).call(method, args).storeResult(storedId).execute();
        return this;
    }
1308478
private String extractQuery(Method method, Object[] args) {
        String res = null;
        String methodName = method.getName();
        if (("execute".equals(methodName) || "executeQuery".equals(methodName) || "executeUpdate".equals(methodName))
                && null != args && 1 == args.length && args[0] instanceof String) {
            res = (String) args[0];
        }
        if (("execute".equals(methodName) || "executeQuery".equals(methodName) || "executeUpdate".equals(methodName))
                && (null == args || 0 == args.length)) {
            res = query;
        }
        return res;
    }
765671
protected MBeanParameterInfo[] getParameters(ExecutableMethod method) {
        return Arrays.stream(method.getArguments()).map(argument -> {
            return new MBeanParameterInfo(argument.getName(), argument.getType().getName(), getParameterDescription(argument));
        }).toArray(MBeanParameterInfo[]::new);
    }
727061
@SuppressWarnings("unchecked")
    public static <T> T execMethod(Method method, Object target, Object... params) {
        allowAccess(method);
        try {
            return (T) method.invoke(target, params);
        } catch (Throwable e) {
            throw new ReflectException(e);
        }
    }