/** * Does parameter types match for var args invocation. * * @param isVarArgs * the is var args * @param parameterTypes * the parameter types * @param arguments * the arguments * @return true, if successful */ private static boolean doesParameterTypesMatchForVarArgsInvocation(boolean isVarArgs, Class<?>[] parameterTypes, Object[] arguments) { if (isVarArgs && arguments != null && arguments.length >= 1 && parameterTypes != null && parameterTypes.length >= 1) { final Class<?> componentType = parameterTypes[parameterTypes.length - 1].getComponentType(); final Object lastArgument = arguments[arguments.length - 1]; if (lastArgument != null) { final Class<?> firstArgumentTypeAsPrimitive = getTypeAsPrimitiveIfWrapped(lastArgument); final Class<?> varArgsParameterTypeAsPrimitive = getTypeAsPrimitiveIfWrapped(componentType); isVarArgs = isVarArgs && varArgsParameterTypeAsPrimitive.isAssignableFrom(firstArgumentTypeAsPrimitive); } } return isVarArgs && areAllArgumentsOfSameType(arguments); }
private static <T> Constructor<T> getPotentialVarArgsConstructor(Class<T> classThatContainsTheConstructorToTest, Object... arguments) { if (areAllArgumentsOfSameType(arguments)) { Constructor<T>[] declaredConstructors = (Constructor<T>[]) classThatContainsTheConstructorToTest .getDeclaredConstructors();
potentialMethodToInvoke = method; } else if (potentialMethodToInvoke.getName().equals(method.getName())) { if (areAllArgumentsOfSameType(arguments) && potentialMethodToInvoke.getDeclaringClass() != method.getDeclaringClass()) {