Cannot cast Comparable<?>s

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 5.0
    • Affects Version/s: 5.0
    • Component/s: tools
    • b51
    • generic
    • generic

      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

            Assignee:
            Neal Gafter (Inactive)
            Reporter:
            Mark Reinhold
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: