Bug 78049

Summary: [1.5][compiler] Missed error for generic array creation.
Product: [Eclipse Project] JDT Reporter: R Lenard <rlenard>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description R Lenard CLA 2004-11-08 01:12:11 EST
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.
Comment 1 Philipe Mulet CLA 2004-11-08 06:45:23 EST
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
Comment 2 Olivier Thomann CLA 2004-12-14 15:46:55 EST
Verified in 200412140800