Bug 79891 - [GENERICS] Array of Inner Class creation works on eclipse, but fails to compile with sun jdk
Summary: [GENERICS] Array of Inner Class creation works on eclipse, but fails to compi...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-01 11:52 EST by Benedikt CLA
Modified: 2004-12-14 22:55 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benedikt CLA 2004-12-01 11:52:05 EST
The Source code below compiles/runs with eclipse 3.1M3 JDT, but not with the sun
java compiler.
I believe it should not compile and produce a "generic array creation" error, as
the sun compiler does.


=== Source ====
public class Collection<Type> {
  private class Element {
    public Type e;
  }
  public Collection() {
    Element[] eArray = new Element[10];
  }
}
=== End Source ===

=== javac output ===

Collection.java:6: generic array creation
    Element[] eArray = new Element[10];

=== End javac output ===
Comment 1 Philipe Mulet CLA 2004-12-01 12:49:41 EST
JLS3rd - 4.7 specifies legite "reifiable" types to be:
• It refers to a non-generic type declaration.
• It is a parameterized type in which all type arguments are unbounded wildcards
(§4.5.1).
• It is a raw type (§4.8).
• It is an array type (§10.1) whose component type is reifiable

Member type "Element" is not generic per se, so this feels a bug in their compiler.
Comment 2 Olivier Thomann CLA 2004-12-01 14:14:52 EST
3 tests among the jck tests reported this error. We pass all of them. They are
not similar cases to this one.
So this might indeed be a bug in javac.
Comment 3 Philipe Mulet CLA 2004-12-01 16:17:53 EST
I think their compiler considers non reifiable a non-static member type from a
generic type. 

Will comply to their implementation since the spec is not clear.
Comment 4 Philipe Mulet CLA 2004-12-09 18:30:47 EST
Added GenericTypeTest#test431-432.
Fixed
Comment 5 Olivier Thomann CLA 2004-12-14 22:55:03 EST
Verified in 200412140800