aboutsummaryrefslogtreecommitdiff
path: root/exec/java-exec/src/main/java/org/apache/drill/exec/compile/JDKClassCompiler.java
diff options
context:
space:
mode:
authorAditya Kishore <aditya@maprtech.com>2014-07-21 16:09:44 -0700
committerJacques Nadeau <jacques@apache.org>2014-07-25 14:34:18 -0700
commit97a9a4c155da4f5a3604c24db7e8ab5ec47797ce (patch)
treee9e1222b1f428d4f8e798abbe25e80cf8b07b376 /exec/java-exec/src/main/java/org/apache/drill/exec/compile/JDKClassCompiler.java
parent2a4d6f1911d86f6a58a175cd1278c06a2d7cade9 (diff)
DRILL-1166: Session option to enable/disable debug information in runtime generated Java code
+ By default, debug options are enabled but can be disabled by setting the session option `exec.java_compiler_debug` to false. + Allow the defaults for compiler options to be set through configuration.
Diffstat (limited to 'exec/java-exec/src/main/java/org/apache/drill/exec/compile/JDKClassCompiler.java')
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/compile/JDKClassCompiler.java20
1 files changed, 5 insertions, 15 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/JDKClassCompiler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/JDKClassCompiler.java
index 2bbf4f848..e1f52cafa 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/JDKClassCompiler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/JDKClassCompiler.java
@@ -36,19 +36,20 @@ import com.google.common.collect.Lists;
class JDKClassCompiler extends AbstractClassCompiler {
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(JDKClassCompiler.class);
- private Collection<String> compilerOptions;
- private DiagnosticListener<JavaFileObject> listener;
+ private final Collection<String> compilerOptions;
+ private final DiagnosticListener<JavaFileObject> listener;
private final JavaCompiler compiler;
private final DrillJavaFileManager fileManager;
- public JDKClassCompiler(ClassLoader classLoader) {
+ public JDKClassCompiler(ClassLoader classLoader, boolean debug) {
+ super(debug);
this.compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
throw new UnsupportedOperationException("JDK Java compiler not available - probably you're running a JRE, not a JDK");
}
this.listener = new DrillDiagnosticListener();
this.fileManager = new DrillJavaFileManager(compiler.getStandardFileManager(listener, null, Charsets.UTF_8), classLoader);
- updateDebugOptions();
+ this.compilerOptions = Lists.newArrayList(this.debug ? "-g:source,lines,vars" : "-g:none");
}
@Override
@@ -80,17 +81,6 @@ class JDKClassCompiler extends AbstractClassCompiler {
}
}
- protected void updateDebugOptions() {
- StringBuilder sb = new StringBuilder("-g:");
- if (this.debugSource) sb.append("source,");
- if (this.debugLines) sb.append("lines,");
- if (this.debugVars) sb.append("vars,");
- if (sb.length() == 3) { // "-g:"
- sb.append("none,");
- }
- compilerOptions = Lists.newArrayList(sb.substring(0, sb.length()-1));
- }
-
protected org.slf4j.Logger getLogger() { return logger; }
}