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

javac fails to generate bridge for override with reordered intersection

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8
    • tools

       public static class Sup {
         <T extends Runnable & Cloneable> void m(T arg) { System.out.println("Sup"); }
       }
       public static class Sub extends Sup {
         <T extends Cloneable & Runnable> void m(T arg) { System.out.println("Sub"); }
       }

      Internally, the compiler treats this as an override. But the generated code includes Sup.m(Runnable)V and Sub.m(Cloneable)V, with no bridge between them.

      ecj 3.8 has the same typing logic, but does generate a bridge.

      Another possible (source-incompatible) approach is to decide that the two intersections are _not_ the same, so no overriding occurs. JLS is not extremely clear on this.

            dlsmith Dan Smith
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: