Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5064736

Incompatible types are cast without error

XMLWordPrintable

    • 5.0
    • 5.0
    • x86
    • windows_xp

        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)
        ======================================================================

              ahe Peter Ahe
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: