JDK-5064736 : Incompatible types are cast without error
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-06-17
  • Updated: 2005-12-30
  • Resolved: 2005-09-26
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.
Other JDK 6
5.0u10Resolved 6Resolved
Related Reports
Duplicate :  
Description
Name: rmT116609			Date: 06/17/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b55)
Java HotSpot(TM) Client VM (build 1.5.0-beta3-b55, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
In the following code:

class A {}
class B extends A {}

public class Foo<T> {
    public <U extends B> void foo(Foo<? super A> param) {
        Foo<U> foo = (Foo<U>)param;
    }
}

casting should fail, since the capture of  ? super A  is not convertible to U
due to bound of U.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compiler must report an error instead of unchecked assignment.

REPRODUCIBILITY :
This bug can be reproduced always.
(Incident Review ID: 280367) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon
07-09-2004

EVALUATION We will check to see precisely what JLS3 says about this situation. ###@###.### 2004-06-17 JLS3 says about (T)S: If S is a class type: If T is a class type, then either |S| <: |T|, or |T| <: |S|; otherwise a compile-time error occurs. ... Since niether Foo<? super A> <: Foo<U> nor Foo<U> <: Foo<? super A> is true, this appears to be a bug. ###@###.### 2004-06-18
18-06-2004