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

Cannot cast Comparable<?>s

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 5.0
    • 5.0
    • tools
    • b51
    • generic
    • generic

    Description

      The following code compiled without any problems on b48.

          public class CI {

      Comparable<?> x;

      void put(Comparable<?> x) { this.x = x; }

      Comparable<?> get() { return x; }

      void test() {
      CI ci = new CI();
      ci.put(new Integer(3));
      Integer x = (Integer)ci.get();
      }

          }

      On b49 it generates the following error message:

          CI.java:15: inconvertible types
          found : java.lang.Comparable<capture of ?>
          required: java.lang.Integer
      Integer x = (Integer)ci.get();
      ^

      Unless I'm mistaken, this code is legal and should compile.

      -- ###@###.### 2004/5/2

      Attachments

        Activity

          People

            gafter Neal Gafter
            mr Mark Reinhold
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: