Community
Participate
Working Groups
Tested on 3.2 M4 I think that the eclipse compiler has missed a potential problem. In the code below javac complains where the comment indicates with the following error, eclipse seems to think that the code is fine: ------------------------ TestGenerics.java:17: warning: [unchecked] unchecked generic array creation of type java.lang.Iterable<java.lang.Integer>[] for varargs parameter this.<Integer>m3(this.<Integer>m(3,3,3,3,3)); ^ 1 warning ------------------------- TestGenerics.java ---------------------- import java.util.Arrays; public class TestGenerics { public <T> Iterable<T> m(T...ts) { return Arrays.asList(ts); } public <T> void m3(Iterable<T> ...ts) { } public void m2() { this.<Integer>m3(this.<Integer>m(3,3,3,3,3)); //javac complains here } } -----------------------------------------
Added support for varargs parameter generic array creation. Will now issue: WARNING in Test.java (at line 15) this.<Integer>m3(this.<Integer>m(3,3,3,3,3)); //javac complains here ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type safety : A generic array of Iterable<Integer> is created for a varargs parameter Added GenericTypeTest#test0949-0952. Fixed
*** Bug 106325 has been marked as a duplicate of this bug. ***
There is indeed a minor API addition (a new problem ID = constant). There is no way this one can be avoided. No one could be dependant upon it, since this problem wasn't detected before, though it should have been. Mike - would you please cast your vote ? The addition is a new constant field on IProblem /** @since 3.2 */ int UnsafeGenericArrayForVarargs = MethodRelated + 574;
I don't see how this could be a problem. +1. ok to proceed.
Verified for 3.2 M6 using build I20060328-0010