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

Specification of casts involving final type is too strict

XMLWordPrintable

    • generic
    • generic

      Javac incorrectly accepts this program in violation
      of the spec:

      class Test<S> {
              void foo() {
                      A a = new A();
                      Comparable<Object> c = (Comparable<Object>)a; // Fails as expected
                      Comparable<S> c2 = (Comparable<S>)a; // Should fail?
              }
              
      }

      final class A implements Comparable<A> {
              public int compareTo(A o) {
                      return 0;
              }
      }

      ###@###.### 2005-05-13 15:37:27 GMT
      This appears to be a specification bug so I have changed
      the synopsis and reassigned the bug.

            abuckley Alex Buckley
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: