JDK-6270087 : Javac rejects legal cast
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P5
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic
  • CPU: generic
  • Submitted: 2005-05-13
  • Updated: 2010-08-23
  • Resolved: 2010-08-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
In this program, only cast 3 should be rejected:

import java.util.List;
public class X<S extends Comparable<S>> {

   Object foo(Comparable<Integer> c) {
         return (Comparable<S>) c; // 1
   }

   <U extends Throwable, V extends Runnable> void foo(List<V> lv) {
         List l = (List<U>) lv; // 2
   }

   <U extends Throwable, V extends Runnable> void foo2(List<List<V>> lv) {
         List l = (List<List<U>>) lv; // 3
   }
}

###@###.### 2005-05-13 15:51:12 GMT

Comments
EVALUATION Not reproducible in JDK 7 after the fix of 6932571.
23-08-2010

WORK AROUND Object foo(Comparable<Integer> c) { return (Comparable) c; // 1 }
27-09-2005

EVALUATION Currently, we don't plan to fix this in Mustang.
27-09-2005

EVALUATION Yes, the cast implementation in javac is wrong. ###@###.### 2005-05-13 15:51:12 GMT
13-05-2005