使用jOOQ 3.6,纯SQL和javac编译器进行慢速编译
|
参见英文答案 >
Troubleshoot slow compilation3个
鉴于bug的一般性质,我在Stack Overflow上将其记录在案,以便其他人在遇到问题时帮助应用变通方法.在较高的层面上,它似乎是由于JEP 101: Generalized Target-Type Inference引起的编译器性能回归,这是在Java 8中引入的,并且在过去已经引起了1-2个问题. 使用Maven和jOOQ 3.7在Windows上使用jdk 1.8.0_60或1.8.0_66编译以下相对无害的类大约需要20秒: 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>
未出现此问题时的配置: >使用jOOQ 3.5(3.6.0之前的任何内容) 解决方法说明在jOOQ 3.6中(当这个问题首次出现时),DSL.field()API看到了22个新的重载,它们将不同的Row类型作为参数: > 看来,上面这个特定的API用法,当javac编译器试图在所有可能的重载中找到最具体的重载时,新的重载会导致很多麻烦.以下解决方法立即编译: 固定 正在修复3.9.0,3.8.1,3.7.4,3.6.5版本,再次从公共API中删除这些方法,并提供不会导致任何重载问题的重命名替换. 解决方法 1.帮助编译器选择最具体的DSL.field()重载 import static org.jooq.impl.DSL.field;
import org.jooq.Field;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
public class Test {
public void method() {
Field<Object> f1 = field("client.id");
Field<Object> f2 = field("client_id");
DSL.using(SQLDialect.MYSQL)
.select()
.where(DSL.trueCondition())
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
.and(f1.eq(f2))
;
}
}
2.完全防止和()方法的上下文中的目标类型推断 import static org.jooq.impl.DSL.field;
import org.jooq.Condition;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
public class Test {
public void method() {
Condition condition = field("client.id").eq(field("client_id"));
DSL.using(SQLDialect.MYSQL)
.select()
.where(DSL.trueCondition())
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
.and(condition)
;
}
}
更多信息 实际上已经在Stack Overflow上报告过: > Troubleshoot slow compilation 它也在jOOQ用户组中讨论过: > https://groups.google.com/forum/#!topic/jooq-user/vuaG9d9krDk (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
