Community
Participate
Working Groups
The code underneath compiles when it should fail. I tried it with M5 and M6. public class TestCasting<S extends Comparable<S>> { public TestCasting() { S a = (S)(Integer)3; // this should fail } }
Still failing using M7 candidate.
Added GenericTypeTest#test661-665. Part of the issue was that when recursing on variable upper bound, it was actually using the upper bound erasure, and the check for final type was not strict enough. Fixed
Verified for 3.1 RC1 with build I20050527-0010.
Humm... actually I now think this code should be accepted, with unchecked warnings. Comparable<S> is not provably distinct from Comparable<Integer>. Interestingly, removing the bounds on S declaration make javac accept this code.
Also see javac bugs in cast conversions: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6270087