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

Incompatible types are cast without error

    Details

    • Subcomponent:
    • Introduced In Build:
      5.0
    • Introduced In Version:
      5.0
    • CPU:
      x86
    • OS:
      windows_xp

      Backports

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

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: