This question already has an answer here:
- Troubleshoot slow compilation 3 answers
The following bug was reported to the jOOQ user group. It really seems to be a bug in the javac compiler related to rather "complex" type inference work done by the compiler in the context of using an internal DSL like jOOQ is.
Given the general nature of the bug, I'm documenting it here on Stack Overflow for others to help apply workarounds if they run into it. On a high level, it seems to be a compiler performance regression due to JEP 101: Generalized Target-Type Inference, which was introduced in Java 8 and has caused 1-2 issues in the past.
The following relatively harmless class takes around 20 seconds to compile with jdk 1.8.0_60 or 1.8.0_66 on Windows using Maven and jOOQ 3.7:
import static org.jooq.impl.DSL.field;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
public class Test {
public void method() {
DSL.using(SQLDialect.MYSQL)
.select()
.where(DSL.trueCondition())
.and(field("client.id").eq(field("client_id")))
.and(field("client.id").eq(field("client_id")))
.and(field("client.id").eq(field("client_id")))
.and(field("client.id").eq(field("client_id")))
.and(field("client.id").eq(field("client_id")))
.and(field("client.id").eq(field("client_id")))
.and(field("client.id").eq(field("client_id")))
.and(field("client.id").eq(field("client_id")))
.and(field("client.id").eq(field("client_id")))
.and(field("client.id").eq(field("client_id")))
;
}
}
pom.xml:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>compilation-issues</groupId>
<artifactId>compilation-issues</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>3.7.1</version>
</dependency>
</dependencies>
</project>
Configurations when this issue doesn't appear:
- Using jOOQ 3.5 (anything prior to 3.6.0)
- Using jOOQ with generated classes rather than the above "plain SQL" API
- Using Java 7
- Using the Eclipse compiler