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

generics: overridden interface method causes the compiler to reject cast

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 1.4.0
    • 1.4.0
    • tools
    • beta2
    • generic
    • solaris_7
    • Verified

    Description

      This is a bug in the jsr14 prototype compiler.

      frog$ cat -n T.java
           1 interface Collection<E> {
           2 <T> T[] toArray(T[] a);
           3 }
           4
           5 interface Set<E> extends Collection<E> {
           6 <T> T[] toArray(T[] a);
           7 }
           8
           9 interface SortedSet<E> extends Set<E> {
          10 }
          11
          12 class TreeSet<E> {
          13 public void addAll(Collection<E> c) {
          14 if (c instanceof SortedSet<E>) {}
          15 }
          16 }
      frog$ make
      /java/jdk/ws/tools/jsr14/build/solaris-sparc/bin/javac -gj *.java
      T.java:14: interfaces Collection<E> and SortedSet<E> are incompatible; both define toArray(T[]), but with different return type
              if (c instanceof SortedSet<E>) {}
                  ^
      1 error
      *** Error code 1
      make: Fatal error: Command failed for target `all'
      frog$

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: