Duplicate :
|
Following java class fails to compile: public class Test15 { interface Iface<T> { String m(T... t); } public static void run() { Iface<? super Integer> i = null; i.m(Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1)); } } The error message is: Error:(10, 10) java: method m in interface Test15.Iface<T> cannot be applied to given types; required: capture#1 of ? super java.lang.Integer[] found: java.lang.Integer,java.lang.Integer,java.lang.Integer reason: formal varargs element type capture#1 of ? super java.lang.Integer is not accessible from class Test15 Removing wild cards from Iface<? super Integer> (turning it into Iface<Integer>) makes compilation to succeed. Also please note following differences we discovered: JDK7: i.m(new Integer[1]); //error i.m(Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1)); //ok JDK8: i.m(new Integer[1]); //ok i.m(Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1)); //error