Community
Participate
Working Groups
Version: 3.2.0 Build id: I20060614-0843 In GenericTypeTest#550, which is copied below for clarity, U must extend B and honor a lower bound of A. But B extends A, hence U cannot satisfy all its bounds, and javac 1.5.0_08 and 6.0 b86 both raise an error. Eclipse only raises an unchecked warning. class A {} class B extends A {} public class X<T> { public <U extends B> void foo(X<? super A> param) { X<U> foo = (X<U>) param; // unchecked warning vs error } }
Cast checks are spec'ed to tolerate such situations where both types are not provably distinct. javac doesn't follow the spec here; but I admit their behavior is more helpful as statically the cast could be rejected based on bound constraints. Need to decide whether we bet on spec to evolve in javac direction or we stick to the spec.
Other symptoms in bug 120088.
Also see bug 170064.
Added GenericTypeTest#test1193
Created attachment 80032 [details] Proposed patch
Tuned GenericTypeTest#test0550
Created attachment 80034 [details] Better patch
Released for 3.4M3. Fixed
Created attachment 80043 [details] Additional change Required to avoid some regression in classlibs (java/lang/Class)
Verified for 3.4 M3 using build I20071029-0010.