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

Redundant generic bridges are generated in some cases

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 7u85, 8, 9
    • Fix Version/s: tbd_major
    • Component/s: tools
    • Labels:

      Description

      A and B are symmetric: A's nested class extends B, B's nested class extends A. Depending on the order of compilation a bridge method is generated in A$Nested or B$Nested, but not both.

      $ cat I.java
      interface I<T> {
        void f(T t);
      }
      $ cat A.java
      class A implements I<Number> {
        public void f(Number x) {}
        static class Nested extends B {
        }
      }
      $ cat B.java
      class B implements I<Number> {
        public void f(Number x) {}
        static class Nested extends A {
        }
      }

      # pass A.java to javac first, A$Nested has a bridge method

      $ rm -f *.class
      $ javac I.java A.java B.java
      $ javap -private 'A$Nested'
      Compiled from "A.java"
      class A$Nested extends B {
        A$Nested();
        public void f(java.lang.Object);
      }
      $ javap -private 'B$Nested'
      Compiled from "B.java"
      class B$Nested extends A {
        B$Nested();
      }

      # pass B.java to javac first, B$Nested has a bridge method

      $ rm -f *.class
      $ javac I.java B.java A.java
      $ javap -private 'A$Nested'
      Compiled from "A.java"
      class A$Nested extends B {
        A$Nested();
      }
      $ javap -private 'B$Nested'
      Compiled from "B.java"
      class B$Nested extends A {
        B$Nested();
        public void f(java.lang.Object);
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mcimadamore Maurizio Cimadamore
              Reporter:
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: