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

generics: bridge method not considered to fulfil interface in abstract class

XMLWordPrintable

    • hopper
    • generic
    • solaris_8

      frog:~/workspaces/test/Generic11 $ ls -la
      total 10
      drwxr-xr-x 2 gafter 512 Feb 4 15:25 .
      drwxr-xr-x 115 gafter 3072 Feb 4 14:48 ..
      -rw-r--r-- 1 gafter 49 Feb 4 14:52 MyColor.java
      -rw-r--r-- 1 gafter 82 Feb 4 14:53 MyComparable.java
      -rw-r--r-- 1 gafter 145 Feb 4 15:25 MyEnum.java
      frog:~/workspaces/test/Generic11 $ cat -n MyComparable.java
           1 interface MyComparable<T extends MyComparable<T>> {
           2 int compareTo(T other);
           3 }
      frog:~/workspaces/test/Generic11 $ cat -n MyEnum.java
           1 class MyEnum<E extends MyEnum<E>> implements MyComparable<E> {
           2 // abstract void f();
           3
           4 public int compareTo(E other) {
           5 return 0;
           6 }
           7 }
      frog:~/workspaces/test/Generic11 $ cat -n MyColor.java
           1 class MyColor extends MyEnum {
           2 void f() {}
           3 }
      frog:~/workspaces/test/Generic11 $ newjavac -gj *.java
      frog:~/workspaces/test/Generic11 $ # now we make MyEnum.java abstract...
      frog:~/workspaces/test/Generic11 $ cat -n MyEnum.java
           1 abstract class MyEnum<E extends MyEnum<E>> implements MyComparable<E> {
           2 // abstract void f();
           3
           4 public int compareTo(E other) {
           5 return 0;
           6 }
           7 }
      frog:~/workspaces/test/Generic11 $ newjavac -gj *.java
      MyColor.java:1: MyColor should be declared abstract; it does not define compareTo(MyComparable) in MyComparable
      class MyColor extends MyEnum {
      ^
      1 error
      frog:~/workspaces/test/Generic11 $

      This problem is also seen when MyEnum is compiled without -gj.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: