mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-13 21:01:01 +08:00
[#2697] Use ECJ compiler on JRE's without compiler for Alias.*
This commit is contained in:
parent
9eeb13f329
commit
15da5c069f
@ -21,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import com.google.common.primitives.Primitives;
|
||||
import com.mysema.codegen.ECJEvaluatorFactory;
|
||||
@ -52,7 +53,7 @@ public class DefaultEvaluatorFactory {
|
||||
|
||||
public DefaultEvaluatorFactory(CollQueryTemplates templates) {
|
||||
this(templates,
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
Thread.currentThread().getContextClassLoader() != null ? Thread.currentThread().getContextClassLoader() : DefaultEvaluatorFactory.class.getClassLoader());
|
||||
}
|
||||
|
||||
public DefaultEvaluatorFactory(CollQueryTemplates templates, EvaluatorFactory factory) {
|
||||
@ -68,10 +69,11 @@ public class DefaultEvaluatorFactory {
|
||||
|
||||
protected DefaultEvaluatorFactory(CollQueryTemplates templates, ClassLoader classLoader) {
|
||||
this.templates = templates;
|
||||
if (classLoader instanceof URLClassLoader) {
|
||||
this.factory = new JDKEvaluatorFactory((URLClassLoader) classLoader);
|
||||
final JavaCompiler systemJavaCompiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (classLoader instanceof URLClassLoader && systemJavaCompiler != null) {
|
||||
this.factory = new JDKEvaluatorFactory((URLClassLoader) classLoader, systemJavaCompiler);
|
||||
} else {
|
||||
// for OSGi compatibility
|
||||
// for OSGi and JRE compatibility
|
||||
this.factory = new ECJEvaluatorFactory(classLoader);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user