New Collection.toArray(IntFunction) Default Method in JDK 11 EA build 22 – Info Java

Yeah. After type erasure, the class will have methods with following signatures:

The deeper issue here is that the language has been designed so that Object[] is not a superclass of “array of class”.

The supertype relation for array types is not the same as the superclass relation. The direct supertype of Integer[] is Number[] according to §4.10.3, but the direct superclass of Integer[] is Object according to the Class object for Integer[] (§10.8). This does not matter in practice, because Object is also a supertype of all array types.

Solving that issue would require a backwards-incompatible change for instances to remember their types at runtime (and tag methods accordingly), so the JVM could infer that you actually want a T or T[] when you call a generic .

Article Prepared by Ollala Corp

You might also like
Leave A Reply

Your email address will not be published.