Incoherent invocation type inference?
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Jan 19 17:09:55 UTC 2017
On 19/01/17 13:44, B. Blaser wrote:
> ... we get a NullPointerException. We could imagine another
> implementation that would invoke "Object[] toArray()" if "a==null". In
> that case we would get a ClassCastException. In all cases, this piece
> of code will fail at runtime with any exception. Then, javac could
> probably emit also a warning in this situation by updating the rule as
> follows:
I don't think I agree with your analysis.
Yes, an impl could delegate to toArray() but then will have to cast from
Object[] to T[], which is an unchecked cast - so a CCE would be well
deserved there.
Maurizio
More information about the compiler-dev
mailing list