Community
Participate
Working Groups
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 ===
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.
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.
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.
Added GenericTypeTest#test431-432. Fixed
Verified in 200412140800