private static Object[] preProcessArguments(ManagedClassSPI managedClass, Member member, Class<?>[] formalParameters, Object... args) {
		switch (args.length) {
		case 0:
			args = new Object[formalParameters.length];
			for (int i = 0; i < args.length; i++) {
				args[i] = getDependencyValue(managedClass, formalParameters[i]);
			}
			break;

		case 1:
			// TODO: refine variable arguments: test for formal parameters type, document and test
			if (args[0] instanceof VarArgs && formalParameters.length == 1 && formalParameters[0].isArray()) {
				args[0] = ((VarArgs<?>) args[0]).getArguments();
			}
			break;
		}

		// arguments validity test against formal parameters: count and types
		if (formalParameters.length != args.length) {
			throw new IllegalArgumentException("Invalid arguments count on method |%s|. Expected |%d| but got |%d|.", member, formalParameters.length, args.length);
		}
		for (int i = 0; i < formalParameters.length; ++i) {
			if (args[i] != null && !Types.isInstanceOf(args[i], formalParameters[i])) {
				throw new IllegalArgumentException("Invalid argument type at position |%d| on method |%s|. Expected |%s| but got |%s|.", i, member, formalParameters[i], args[i].getClass());
			}
		}
		return args;
	}
private static Object [ ] preProcessArguments ( ManagedClassSPI managedClass , Member member , Class < ? > [ ] formalParameters , Object ... args ) { switch ( args . length ) { case 0 : args = new Object [ formalParameters . length ] ; for ( int i = 0 ; i < args . length ; i ++ ) { args [ i ] = getDependencyValue ( managedClass , formalParameters [ i ] ) ; } break ; case 1 : if ( args [ 0 ] instanceof VarArgs && formalParameters . length == 1 && formalParameters [ 0 ] . isArray ( ) ) { args [ 0 ] = ( ( VarArgs < ? > ) args [ 0 ] ) . getArguments ( ) ; } break ; } if ( formalParameters . length != args . length ) { throw new IllegalArgumentException ( "Invalid arguments count on method |%s|. Expected |%d| but got |%d|." , member , formalParameters . length , args . length ) ; } for ( int i = 0 ; i < formalParameters . length ; ++ i ) { if ( args [ i ] != null && ! Types . isInstanceOf ( args [ i ] , formalParameters [ i ] ) ) { throw new IllegalArgumentException ( "Invalid argument type at position |%d| on method |%s|. Expected |%s| but got |%s|." , i , member , formalParameters [ i ] , args [ i ] . getClass ( ) ) ; } } return args ; }
Update and validate invocation arguments against given formal parameter types. If formal parameters is not empty but no
invocation arguments this method will inject dependency using {@link #getDependencyValue(ManagedClassSPI, Class)}. This
method also performs arguments validity check against formal parameters throwing illegal arguments if validation fails.

@param managedClass managed class owning constructor or method,
@param member constructor or method for given arguments,
@param formalParameters formal parameter types,
@param args constructor or method invocation arguments.
@return given arguments updated and validated.