type inference exponential compilation performance

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 9
    • Affects Version/s: None
    • Component/s: tools
    • 8
    • generic
    • generic

      20 lines source takes an HOUR to compile:

      class C<U> {
          U fu;
          C() {}
          C(C<U> other) { this.fu = other.fu; }
          C(U fu) { this.fu = fu; }

          static <U> C<U> m(C<U> src) { return new C<U>(src); }

          public static void main(String argv[]) {
              /* type inference is expected here: */
              C<String> c2 = m(new C<>(m(new C<>() )) );
              C<String> c3 = m(new C<>(m(new C<>(m(new C<>() )) )) );
              C<String> c4 = m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) ); // Javac(1.04), ECJ(.71s)
              C<String> c5 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) ); // Javac(2.02s), ECJ(1.17s)
              C<String> c6 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) )) ); // Javac(4.84s) ECJ(1.67s)
              C<String> c7 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) )) )) ); // Javac(14.99s) ECJ(10.82s)
              C<String> c8 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) )) )) )) ); // Javac(79.62s) ECJ(134.64s)
              C<String> c9 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>() )) )) )) )) )) )) )) )) ); // Javac(437s) ECJ(1305s)
              C<String> c10 = m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>(m(new C<>()))))))))))))))))))); // 3600
          }
      }

      Each lines show how long it takes to compile it in seconds.
      Time is about the same for original jdk8.0 and latest jdk8u20 and jdk9.

            Assignee:
            Vicente Arturo Romero Zaldivar
            Reporter:
            Leonid Arbuzov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: