This is similar to a bug recently introduced in javac .
The argument in the call to f(..) explicitly of type String[] . This can be shown, for example, by resolving the same expression as a stand-alone expression:
String s1 = Stream.of("xxx").toArray(i -> new String[i])[0]; String[] s2 = Stream.of("xxx").toArray(i -> new String[i]).clone();
These accepted by all versions of compilers.
Clearly, f(Integer[]) not applicable with an argument of type String[] . I donβt see the reasons why the external output outputs the internal resolution to a worse result (for example, Object[] ) than the resolution as a separate expression.
Additional evidence: the following statement is correctly rejected even by those versions of javac affected by this error:
Integer[] s3 = Stream.of("xxx").toArray(i -> new String[i]);
Therefore, f(Integer[]) clearly does not correspond to the calculation.
Stephan herrmann
source share