Casting reference array to any-T array.
Michael Barker
mikeb01 at gmail.com
Wed Jan 7 21:19:04 UTC 2015
Hi,
A small thing that tripped me up yesterday. The following code:
package github.mikeb01;
public class C<any T>
{
T[] values;
public C()
{
values = (T[]) new Object[0];
}
public static void main(String[] args)
{
new C<int>();
}
}
Compiles without error, but fails a runtime with:
Specializing github.mikeb01.C${0=I}; searching for github/mikeb01/C.class
(not found)
Specializing github.mikeb01.C${0=I}; searching for github/mikeb01/C.class
(found)
Exception in thread "main" java.lang.IllegalStateException: [I
at
valhalla.specializer.SignatureSpecializer.asClassName(SignatureSpecializer.java:79)
at
valhalla.specializer.SignatureSpecializer$ForType.getDescAsClassName(SignatureSpecializer.java:156)
Should that be a compile time failure, with an invalid cast from a
reference array to any-T array?
Mike.
More information about the valhalla-dev
mailing list