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

erroneus "inconvertible types" error

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000

      Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Upon compiling the given test case, javac complains as follows:
      C:\A.java:5: inconvertible types
      found : X<capture of ? extends java.lang.Object>
      required: X2
            m3((X2) m());
                     ^
      1 error

      I originally thought it was an eclipse bug but there are compelling arguements to say that it should compile with a warning instead. For details please read the eclipse bug report:
      https://bugs.eclipse.org/bugs/show_bug.cgi?id=86898


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Save the code as A.java
      2. javac A.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      compilation should work and there should only be a warning stating that the case is unsafe
      ACTUAL -
      compiler error
      C:\eclipse\workspace\Scratch\src\A.java:5: inconvertible types
      found : X<capture of ? extends java.lang.Object>
      required: X2
            m3((X2) m());
                     ^
      1 error

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class B extends A<Object>
      {
         void m2()
         {
            m3((X2) m());
         }
         
         void m3(X2 i)
         {
            
         }
      }
      public class A<T>
      {
         X<? extends T> m()
         {
            return null;
         }
         
      }

      class X2 extends X<String>
      {
         
      }

      class X<T>
      {
         
      }

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ahe Peter Ahe
                Reporter:
                jleesunw Jon Lee (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: