Community
Participate
Working Groups
Version: 3.2.0 Build id: I20060614-0843 The following source code: import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class X { public static void main(String[] args) { Set<X> set = new HashSet<X>(); for (Iterator<X> iterator = set.iterator(); iterator.hasNext();) { Set<X> element = (Set<X>) iterator.next(); // warning } } } gets an unchecked warning on the cast with javac 1.5.0_08 and 6.0 b86. Eclipse does not complain. Arguably, the return type of iterator.next() is X, which cannot be cast to Set<X>. Note that (boolean) iterator.next() or (Integer) iterator.next() both raise plain errors with javac and eclipse. All other things being equal, getting X to implement Set<X> silences the unchecked warning raised by javac.
See GenericTypeTest#252, which trigerred the bug. (Checked that removing the error on channels does not improve the situation.)
Reproduced with HEAD.
Added GenericTypeTest#test1062-1064
Created attachment 52944 [details] Proposed patch
Released for 3.3M3. Fixed
Verified for 3.3 M3 using build I20061030-0010
Verified using I20061030-1704 and not I20061030-0010