Set the method target of a MethodCallExpression to the first matching method with same number and type of arguments.

@param methodCallExpression
@param targetClass
@param targetParameterClassTypes
@return The method call expression
187612
public static MethodCallExpression applyMethodTarget(final MethodCallExpression methodCallExpression, final Class<?> targetClass, final Class<?>... targetParameterClassTypes) {
        return applyMethodTarget(methodCallExpression, ClassHelper.make(targetClass).getPlainNodeReference(), convertTargetParameterTypes(targetParameterClassTypes));
    }
262822
public static Set<String> getPropertyNames(final Class<?> targetClass)
   {
      HashSet<String> set = new HashSet<>();
      Matcher matcher = GETTER_PATTERN.matcher("");
      for (Method method : targetClass.getMethods()) {
         String name = method.getName();
         if (method.getParameterTypes().length == 0 && matcher.reset(name).matches()) {
            name = name.replaceFirst("(get|is)", "");
            try {
               if (targetClass.getMethod("set" + name, method.getReturnType()) != null) {
                  name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
                  set.add(name);
               }
            }
            catch (Exception e) {
               // fall thru (continue)
            }
         }
      }

      return set;
   }
979565
private void setFunctionCaller(MethodDeclaration method, ExecutableElement methodElement) {
    TypeMirror returnType = methodElement.getReturnType();
    TypeElement declaringClass = ElementUtil.getDeclaringClass(methodElement);
    Block body = new Block();
    method.setBody(body);
    method.removeModifiers(Modifier.NATIVE);
    List<Statement> stmts = body.getStatements();
    FunctionInvocation invocation =
        new FunctionInvocation(newFunctionElement(methodElement), returnType);
    List<Expression> args = invocation.getArguments();
    if (!ElementUtil.isStatic(methodElement)) {
      args.add(new ThisExpression(declaringClass.asType()));
    }
    for (SingleVariableDeclaration param : method.getParameters()) {
      args.add(new SimpleName(param.getVariableElement()));
    }
    if (TypeUtil.isVoid(returnType)) {
      stmts.add(new ExpressionStatement(invocation));
      if (ElementUtil.isConstructor(methodElement)) {
        stmts.add(new ReturnStatement(new ThisExpression(declaringClass.asType())));
      }
    } else {
      stmts.add(new ReturnStatement(invocation));
    }
  }
1167989
@Override
    public void setTargetType(String newTargetType) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setTargetType", newTargetType);

        // Check for null and empty string, and set to default value if found
        if ((newTargetType == null) || ("".equals(newTargetType))) {
            jcaManagedConnectionFactory.setTargetType(ApiJmsConstants.TARGET_TYPE_BUSMEMBER);
        }
        // Ensure that the value is one of the permitted constants - thrown an exception if not
        else if ((ApiJmsConstants.TARGET_TYPE_BUSMEMBER.equals(newTargetType))
                 || (ApiJmsConstants.TARGET_TYPE_CUSTOM.equals(newTargetType))
                 || (ApiJmsConstants.TARGET_TYPE_ME.equals(newTargetType))) {
            jcaManagedConnectionFactory.setTargetType(newTargetType);
        }
        else {
            throw (JMSException) JmsErrorUtils.newThrowable(
                                                            JMSException.class,
                                                            "INVALID_VALUE_CWSIA0261",
                                                            new Object[] { "remoteTargetType", newTargetType },
                                                            tc
                            );
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setTargetType");
    }
872519
@Override
    public void setTarget(Object target) {
        if (mTarget != target) {
            final Object oldTarget = mTarget;
            mTarget = target;
            if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) {
                return;
            }
            // New target type should cause re-initialization prior to starting
            mInitialized = false;
        }
    }
681920
static Method lookupMethod(Class<?> javaClass, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {
        if (System.getSecurityManager() != null) {
            try {
                return AccessController.doPrivileged(new MethodLookupAction(javaClass, methodName, parameterTypes));
            } catch (PrivilegedActionException e) {
                if (e.getCause() instanceof NoSuchMethodException) {
                    throw (NoSuchMethodException) e.getCause();
                }
                throw new WeldException(e.getCause());
            }
        } else {
            return MethodLookupAction.lookupMethod(javaClass, methodName, parameterTypes);
        }
    }
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);
		}
	}
1328739
public static Method findSetter(Class<?> onClass, Class<?> targetClass) {
        Method[] methods = onClass.getMethods();
        for (Method method : methods) {
            Class<?>[] ptypes = method.getParameterTypes();
            if (method.getName().startsWith("set") && ptypes.length == 1 && ptypes[0] == targetClass) { //$NON-NLS-1$
                return method;
            }
        }
        return null;
    }
1088686
protected function callSpecifiedMethod(
        ReflectionMethod $reflectedMethod, 
        $targetObject, 
        $paramsWithSelectors
    ) {
        $args = $this->paramListGenerator->getOrderedListOfArgumentValue(
            $reflectedMethod,
            $paramsWithSelectors
        );
        return $reflectedMethod->invokeArgs($targetObject, $args);
    }
1323143
public SelectParameters withExpressionType(ExpressionType expressionType) {
        setExpressionType(expressionType == null ? null : expressionType.toString());
        return this;
    }
851495
public static <E> Set<E> setify(ObjectMapper mapper, Object source, Class<E> targetElementType) {
        return (Set<E>) collectify(mapper, source, Set.class, targetElementType);
    }
1321585
@Override
	public Object invokeMethod(Object... args) {
		Assert.state(this.parameterTypes.length == args.length,
				"Wrong number of arguments, expected no more than: ["
						+ this.parameterTypes.length + "]");

		try {
			// Extract the target from an Advised as late as possible
			// in case it contains a lazy initialization
			Object target = extractTarget(this.object, this.method);
			return method.invoke(target, args);
		}
		catch (Exception e) {
			throw new IllegalArgumentException("Unable to invoke method: [" + this.method
					+ "] on object: [" + this.object + "] with arguments: ["
					+ Arrays.toString(args) + "]", e);
		}
	}
1123133
private static Matcher<ExpressionTree> methodReceiverHasType(final Set<String> typeSet) {
    return new Matcher<ExpressionTree>() {
      @Override
      public boolean matches(ExpressionTree expressionTree, VisitorState state) {
        Type receiverType = ASTHelpers.getReceiverType(expressionTree);
        return typeSet.contains(receiverType.toString());
      }
    };
  }
48054
public void executeMethod(final Class<?> targetClass, final Method targetMethod, final Object[] methodArgs)
            throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {

        addImplementationClasses(targetClass);

        if (methodArgs != null) {
            targetMethod.invoke(instanceMap.get(targetClass), methodArgs);
        } else {
            targetMethod.invoke(instanceMap.get(targetClass));
        }
    }
699221
private CodeBlock methodCallCodeWithClassParameters( MapperInstance instance, ImmutableList<? extends JType> parameters ) {
        CodeBlock.Builder builder = initMethodCallCode( instance );
        return methodCallParametersCode( builder, Lists.transform( parameters, new Function<JType, CodeBlock>() {

            @Override
            public CodeBlock apply( JType jType ) {
                return CodeBlock.builder().add( "$T.class", typeName( jType ) ).build();
            }
        } ) );
    }
755539
public void setMethodTarget(MethodNode mn) {
        this.target = mn;
        if (mn!=null) {
            setType(target.getReturnType());
        } else {
            setType(ClassHelper.OBJECT_TYPE);
        }
    }
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);
	}