带有单个参数的Java varargs给出了“不清楚varargs是否调用”,尽管有人施放

时间:2016-08-19 15:16:29

标签: java generics variadic-functions

我已阅读this,它应该可以解决我的问题,但在这两种情况下我仍然会收到Confusing argument '(Class<?>[])null', unclear if a varargs or non-varargs call is desired警告:

public class MultiArgument<T, E> implements Argument {
    private final Argument[] args;
    private final Class<T> type;
    private final New<T, E> maker;

    public MultiArgument(E enclosingInstance, Class<T> type, Argument... args) throws NoSuchMethodException {
        this.type = type;
        this.args = args;
        this.maker = New.create(enclosingInstance, type,
                (Class<?>[]) (ArrayUtils.<Argument, Class<?>>transform(args, Argument::getReturnType))); // here
        New.create(null, null, (Class<?>[])null); // and even here.
    }
...
}

New.create

public static <T, E> New<T, E> create(E enclosingInstance, Class<T> type, Class<?>... argTypes) throws NoSuchMethodException {
    return new New<>((Class<E>) enclosingInstance.getClass(), enclosingInstance, type, argTypes);
}

完整的New.java,以防万一:http://pastebin.com/rtCVkiGX

0 个答案:

没有答案