gwt /
gwt /
b31d067141945cdfc397da9402a6210490c6a233 Wrong ClassCastException with varargs of uninstantiable type.
If there is a vararg of an uninstatiable type Foo as in the following
example,
m(Foo... foos) {
...
}
fooArr = m();
the compiler might emit the following code for the call
fooArr = (null[]) /* inlined code for m() */;
Such call will fail at runtime as the compiler determines that Foo[]
can not be cast to null[].
Three options were considered.
1. Make a cast from Foo[] to null[] succeed if Foo is not
instantiable.
2. Make the JNewArray AST node by of type null[] if its base type
was not instantiable.
3. Don't model at all null[], i.e. don't let an array be tightned
to null[].
The drawbacks of 1 and 2 is loss of information by transforming casts
to different array classes to (null[]).
The drawback of 3 is potential increase in codesize which does not
seem to occurr in practice.
Bug: issue 8736.
Change-Id: I3348836b78ad59e11685a3a55650df81afa75269
4 files changed