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

javac 1.8 very slow with nested generics expressions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u45
    • tools
    • x86_64
    • windows_7
    • Verified

      FULL PRODUCT VERSION :
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Javac 1.8 compiler is running very slow when sompiling a class with several generic methods.
      The compilation of the class from the test case takes 11 seconds.
      Adding one additional generic method like this
       public static <T> PropertyValue<T> with(Property<T> property, Donor<T> valueDonor) {
              return null;
          }
      increases compilation time by a factor of 5!
      Adding additional type parameter to some of the methods also increases the compilation time by a single-digit factor.

      Compilation of the same code using language level of 1.7 takes less than one second.

      In a real project (like mine) after migration from 1.7 to 1.8 language level the compilation takes more than 15 minutes per class.

      ADDITIONAL REGRESSION INFORMATION:
      Using 1.7 language level compilation of the same class takes less than one second:
      javac -source 1.7 src/main/java/frol/NestedExpressionBug_011.java

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile provided test class:
      javac NestedExpressionBug_011.java


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compilation takes less than one second on Intel Xeon CPU E3-1240 @ 3.40 GHz

      ACTUAL -
      Compilation takes more than 10 seconds on Intel Xeon CPU E3-1240 @ 3.40 GHz

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package frol;

      import java.util.List;

      /**
       * Compilation takes 11 Seconds.
       */
      public class NestedExpressionBug_011 {
          public interface PropertyLookup<T> {}
          public interface Instantiator<T> {}
          public class Property<T> {}
          public class PropertyValue<T> {}
          public interface Donor<T> {}
          public class Maker<T> implements PropertyLookup<T>, Donor<T> {}

          public static <T> T make(Maker<T> maker) {
              return null;
          }

          public static <T> Maker<T> a(Instantiator<T> instantiator, PropertyValue... propertyProviders) {
              return null;
          }

          public static <T> PropertyValue<T> with(Property<T> property, T value) {
              return null;
          }

          public static <T> Donor<List<T>> listOf(final Donor... donors) {
              return null;
          }
          public void setUp() {
              make(
                      a(null,
                              with((Property<Object>) null,
                                      listOf(a(null,
                                              with((Property<Object>) null,
                                                      listOf(a(null,
                                                              with(
                                                                      (Property<Object>) null,
                                                                      listOf(
                                                                              a(null,
                                                                                      with((Property<Object>) null,
                                                                                              (List<Object>) null
                                                                                      ))
                                                                      )
                                                              )))
                                              )))
                              )
                      ));

          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      package frol;



      import java.util.List;

      /**
       * Compilation takes 1 second.
       */
      public class NestedExpressionBug_011_workaround {
          public interface PropertyLookup<T> {}
          public interface Instantiator<T> {}
          public class Property<T> {}
          public class PropertyValue<T> {}
          public interface Donor<T> {}
          public class Maker<T> implements PropertyLookup<T>, Donor<T> {}

          public static <T> T make(Maker<T> maker) {
              return null;
          }

          public static <T> Maker<T> a(Instantiator<T> instantiator, PropertyValue... propertyProviders) {
              return null;
          }

          public static <T> PropertyValue<T> with(Property<T> property, T value) {
              return null;
          }

          public static <T> Donor<List<T>> listOf(final Donor... donors) {
              return null;
          }
          public void setUp() {

              Maker<Object> maker = a(null,
                      with((Property<Object>) null,
                              (List<Object>) null
                      ));

              Donor<List<Object>> listDonor = listOf(a(null,
                      with(
                              (Property<Object>) null,
                              listOf(
                                      maker
                              )
                      )));

              make(
                      a(null,
                              with((Property<Object>) null,
                                      listOf(a(null,
                                              with((Property<Object>) null,
                                                      listDonor
                                              )))
                              )
                      ));

          }
      }


      SUPPORT :
      YES

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: