Community
Participate
Working Groups
I read somewhere that creation of generic arrays is not allowed and the results of JAVAC seem to confirm this. % cat X.java public class X { public static void main(String[] args) { Comparable<String>[] X = { }; System.err.println("X.toString() " + X.toString()); Comparable<String>[] Y = new Comparable<String>[] { }; } } % javac X.java c:/Eclipse/Fooey/src/X.java:4: generic array creation Comparable<String>[] X = { ^ c:/Eclipse/Fooey/src/X.java:8: generic array creation Comparable<String>[] Y = new Comparable<String>[] { ^ 2 errors However 3.1M3 doesn't detect the first as a problem.
Array initializers of generic array type should indeed be rejected (currently only rejecting array alloc expr). Added regression test: GenericTypeTest#test393. Tricky case is array alloc combined with trailing initializer, should only issue one error report: e.g. new List<String[]{} Fixed
Verified in 200412140800