Community
Participate
Working Groups
The following example compiles without error with sun compiler, but it gives an error with Eclipse compiler: public class testGeneric2<A> { void method() { class t2<C,D> {}; t2<?,?>[] at = new t2<?,?>[5]; } }
Using javac1.6b74: testGeneric2.java:5: generic array creation t2<?,?>[] at = new t2<?,?>[5]; ^ 1 error
I am almost sure that the code is correct. Because it is necessary. Otherwise it would be imposible to create an array of inner generic classes. With generic classes one cannot create arrays of concrete generic classes, because there are some kind of errors that would not be caught by the compiler. So one has the alternative of creating arrays of unbound generic classes. With this error, this alternative becomes void.
The enclosing type must be reifiable too, in your case it is not. t2<?,?> has testGeneric2<A> as its enclosing type, which isn't reifiable. In a static method, this should be allowed though, as no enclosing type pertains there.
We actually missed the static method scenario. Added GenericTypeTest#test0954. Fixed
forgot to assign
fixed
Thanks, in my case it was a static method, so this fix will be useful for me.
Verified for 3.2 M6 using build I20060328-0010