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

javac compilation very slow with generics

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 8u45
    • tools
    • x86
    • windows_8

      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.3.9600]

      A DESCRIPTION OF THE PROBLEM :
      The attached Test class contains two methods: "slow" and "fast". The only difference between the two methods is that an expression has been extracted as a variable in the "fast" method.

      When the "slow" method is commented out, the class compiles in less than a second. When the "slow" method is NOT commented out, the class compiles in 15+ seconds.

      Unfortunately we haven't been able to reproduce the problem without the JOOQ dependency which uses generics heavily (www.jooq.org).

      REGRESSION. Last worked in version 7u80

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a new maven project, update the pom file as indicated and compile with "mvn clean compile".

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compilation < 1 second
      ACTUAL -
      Compilation > 15 seconds

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      pom.xml (properties and dependencies sections only)

      ------------------------------

        <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <maven.compiler.source>1.8</maven.compiler.source>
          <maven.compiler.target>1.8</maven.compiler.target>
        </properties>

        <dependencies>
          <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-meta</artifactId>
            <version>3.6.1</version>
          </dependency>
        </dependencies>

      --------------------------------

      Test.java

      --------------------------------

      import org.jooq.DSLContext;
      import org.jooq.Field;
      import static org.jooq.impl.DSL.field;
      import static org.jooq.impl.DSL.round;
      import static org.jooq.impl.DSL.sum;

      class Test {
        static Object fast(DSLContext sql) {
          Field<Double> a = field("a").cast(Double.class);
          return sql.select()
                  .having(round(sum(a).cast(Double.class), 2).ne(0d));
        }
        static Object slow(DSLContext sql) {
          return sql.select()
                  .having(round(sum(field("a").cast(Double.class)).cast(Double.class), 2).ne(0d));
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      compiling with -source 1.7 solves the issue but with the obvious caveat that Java 8 syntax does not compile any more...

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

              Created:
              Updated:
              Resolved: