<X> X foo(List<? super X> list)
{
return null;
}
void test()
{
List<Number> list = ...;
String s1 = this.foo(list);
}
The last line makes no sense, how can javac resolve this?
Now the method foo()also makes no sense; it should return null, there is no other value that can be returned by the safe type. Therefore, the last line at run time will not cause any problems: assigns a null value to the String variable.
However, statically, why is the last line compiled? ( javac 1.6 u21 b06 )
source
share