A new helper method Arrays.asArray
timo.kinnunen at gmail.com
timo.kinnunen at gmail.com
Wed Jun 15 01:14:46 UTC 2016
The same issue is present even without any varargs or generics present, when using plain old arrays:
String[] list1 = new String[1];
list1[0] = "hello";
Integer[] list2 = new Integer[1];
list2[0] = 1;
String[][] array = {list1, null};
Object[][] array2 = array;
array2[1] = list2;
for(String[] l : array) {
System.out.println(l[0]);
}
Both issues stem from these unsafe implicit conversions which don’t get a warning:
private static List<?>[] implicit1(List<String>[] it) {
return it;
}
private static Object[][] implicit2(String[][] it) {
return it;
}
I don’t like these conversions either but I don’t see them directly relevant to introducing an Arrays.asArray()-method.
If you want to try to introduce mandatory warnings for these conversions I will definitely cheer you on!
--
Have a nice day,
Timo
Sent from Mail for Windows 10
From: forax at univ-mlv.fr
More information about the core-libs-dev
mailing list