You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Bruce Irschick (Jira)" <ji...@apache.org> on 2021/06/09 21:30:00 UTC

[jira] [Comment Edited] (CALCITE-3745) UnitCompiler can not find required class information.

    [ https://issues.apache.org/jira/browse/CALCITE-3745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17360404#comment-17360404 ] 

Bruce Irschick edited comment on CALCITE-3745 at 6/9/21, 9:29 PM:
------------------------------------------------------------------

@vlsi / @gr4ve

Independent of where you get your class loader, you'll need to update to the latest version of Janino to be able to pass your intended class loader to get their default compiler factory.

Here are my suggestions for updating to Janino.

Note: there is still a bug in the Janino code that is not passing the class loader to load the factory class. I've left a [comment]([https://github.com/janino-compiler/janino/issues/141#issuecomment-858078770]) with the author to resolve the issue.
 [https://github.com/janino-compiler/janino/issues/141#issuecomment-858078770]

So, in the end, we'll need to update to version 3.1.5, assuming the fix is completed in that version.

 

```
 .../apache/calcite/adapter/enumerable/EnumerableInterpretable.java | 5 +++--
 .../main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java | 5 +++--
 .../org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java | 5 +++--
 core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java | 4 ++--
 gradle.properties | 2 +-
 .../apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java | 5 +++--
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpretable.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpretable.java
 index 616ef22f1..51571e419 100644
 — a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpretable.java
 +++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpretable.java
 @@ -134,8 +134,9 @@ public static Bindable toBindable(Map<String, Object> parameters,
 static Bindable getBindable(ClassDeclaration expr, String s, int fieldCount)
 throws CompileException, IOException, ExecutionException {
 ICompilerFactory compilerFactory;
 + final ClassLoader classLoader = EnumerableInterpretable.class.getClassLoader();
 try

{ - compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(); + compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(classLoader); } catch (Exception e) \{ throw new IllegalStateException( "Unable to instantiate java compiler", e); @@ -147,7 +148,7 @@ static Bindable getBindable(ClassDeclaration expr, String s, int fieldCount) fieldCount == 1 ? new Class[] \{Bindable.class, Typed.class}
 : new Class[] \{ArrayBindable.class});
 - cbe.setParentClassLoader(EnumerableInterpretable.class.getClassLoader());
 + cbe.setParentClassLoader(classLoader);
 if (CalciteSystemProperty.DEBUG.value()) {
 // Add line numbers to the generated janino class
 cbe.setDebuggingInformation(true, true, true);
 diff --git a/core/src/main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java b/core/src/main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java
 index 8f244459b..5258d5428 100644
 — a/core/src/main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java
 +++ b/core/src/main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java
 @@ -199,8 +199,9 @@ public JaninoRexCompiler(RexBuilder rexBuilder) {
 static Scalar.Producer getScalar(ClassDeclaration expr, String s)
 throws CompileException, IOException {
 ICompilerFactory compilerFactory;
 + final ClassLoader classLoader = JaninoRexCompiler.class.getClassLoader();
 try \{ - compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(); + compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(classLoader); }

catch (Exception e) {
 throw new IllegalStateException(
 "Unable to instantiate java compiler", e);
 @@ -208,7 +209,7 @@ public JaninoRexCompiler(RexBuilder rexBuilder)

{ IClassBodyEvaluator cbe = compilerFactory.newClassBodyEvaluator(); cbe.setClassName(expr.name); cbe.setImplementedInterfaces(new Class[] \\{Scalar.Producer.class}

);
 - cbe.setParentClassLoader(JaninoRexCompiler.class.getClassLoader());
 + cbe.setParentClassLoader(classLoader);
 if (CalciteSystemProperty.DEBUG.value()) {
 // Add line numbers to the generated janino class
 cbe.setDebuggingInformation(true, true, true);
 diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java b/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
 index 76106c938..a4c31e612 100644
 -- 
 --- a/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
 +++ b/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
 @@ -423,15 +423,16 @@ private static StringBuilder paramList(StringBuilder buff, Method method) {
 String classBody, MetadataDef<M> def,
 List<Object> argList) throws CompileException, IOException {
 final ICompilerFactory compilerFactory;
 + final ClassLoader classLoader = JaninoRexCompiler.class.getClassLoader();
 try \{ - compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(); + compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(classLoader); } catch (Exception e) \{ throw new IllegalStateException( "Unable to instantiate java compiler", e); }
 
 final ISimpleCompiler compiler = compilerFactory.newSimpleCompiler();
 - compiler.setParentClassLoader(JaninoRexCompiler.class.getClassLoader());
 + compiler.setParentClassLoader(classLoader);
 
 final String s = "public final class " + className
 + " implements " + def.handlerClass.getCanonicalName() + " {\n"
 diff --git a/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java b/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
 index 001a0bf16..d4ca4b3ae 100644
 — a/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
 +++ b/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
 @@ -19,10 +19,10 @@
 import org.apache.calcite.config.CalciteSystemProperty;
 
 import org.checkerframework.checker.nullness.qual.Nullable;
 +import org.codehaus.commons.compiler.util.resource.MapResourceFinder;
 +import org.codehaus.commons.compiler.util.resource.ResourceFinder;
 import org.codehaus.janino.JavaSourceClassLoader;
 import org.codehaus.janino.util.ClassFile;
 -import org.codehaus.janino.util.resource.MapResourceFinder;
 -import org.codehaus.janino.util.resource.ResourceFinder;
 
 import java.io.File;
 import java.io.FileOutputStream;
 diff --git a/gradle.properties b/gradle.properties
 index ac11bbcf0..7b8da5a11 100644
 — a/gradle.properties
 +++ b/gradle.properties
 @@ -106,7 +106,7 @@ hydromatic.tpcds.version=0.4
 innodb-java-reader.version=1.0.10
 jackson-databind.version=2.9.10.1
 jackson.version=2.10.0
 -janino.version=3.0.11
 +janino.version=3.1.4
 java-diff.version=1.1.2
 jcip-annotations.version=1.0-1
 jcommander.version=1.72
 diff --git a/ubenchmark/src/jmh/java/org/apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java b/ubenchmark/src/jmh/java/org/apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java
 index fe5ed0d2f..0807ebe19 100644
 — a/ubenchmark/src/jmh/java/org/apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java
 +++ b/ubenchmark/src/jmh/java/org/apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java
 @@ -184,8 +184,9 @@ public void setup() {
 Expressions.toString(info.classExpr.memberDeclarations, "\n", false);
 
 ICompilerFactory compilerFactory;
 + final ClassLoader classLoader = EnumerableInterpretable.class.getClassLoader();
 try \{ - compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(); + compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(classLoader); }
catch (Exception e)
Unknown macro: \{ throw new IllegalStateException( "Unable to instantiate java compiler", e);@@ -197,7 +198,7 @@ public void setup() { plan.getRowType().getFieldCount() == 1 ? new Class[]\{Bindable.class, Typed.class} }
);

 - cbe.setParentClassLoader(EnumerableInterpretable.class.getClassLoader());
 + cbe.setParentClassLoader(classLoader);
 info.cbe = cbe;
 planInfos[i] = info;
 }
 ```

 

 


was (Author: birschick):
@vlsi / @gr4ve

Independent of where you get your class loader, you'll need to update to the latest version of Janino to be able to pass your intended class loader to get their default compiler factory.

Here are my suggestions for updating to Janino.

Note: there is still a bug in the Janino code that is not passing the class loader to load the factory class. I've left a [comment](https://github.com/janino-compiler/janino/issues/141#issuecomment-858078770) with the author to resolve the issue.
https://github.com/janino-compiler/janino/issues/141#issuecomment-858078770

So, in the end, we'll need to update to version 3.1.5, assuming the fix is completed in that version.

```
 .../apache/calcite/adapter/enumerable/EnumerableInterpretable.java | 5 +++--
 .../main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java | 5 +++--
 .../org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java | 5 +++--
 core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java | 4 ++--
 gradle.properties | 2 +-
 .../apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java | 5 +++--
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpretable.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpretable.java
index 616ef22f1..51571e419 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpretable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableInterpretable.java
@@ -134,8 +134,9 @@ public static Bindable toBindable(Map<String, Object> parameters,
 static Bindable getBindable(ClassDeclaration expr, String s, int fieldCount)
 throws CompileException, IOException, ExecutionException {
 ICompilerFactory compilerFactory;
+ final ClassLoader classLoader = EnumerableInterpretable.class.getClassLoader();
 try {
- compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
+ compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(classLoader);
 } catch (Exception e) {
 throw new IllegalStateException(
 "Unable to instantiate java compiler", e);
@@ -147,7 +148,7 @@ static Bindable getBindable(ClassDeclaration expr, String s, int fieldCount)
 fieldCount == 1
 ? new Class[] \{Bindable.class, Typed.class}
 : new Class[] \{ArrayBindable.class});
- cbe.setParentClassLoader(EnumerableInterpretable.class.getClassLoader());
+ cbe.setParentClassLoader(classLoader);
 if (CalciteSystemProperty.DEBUG.value()) {
 // Add line numbers to the generated janino class
 cbe.setDebuggingInformation(true, true, true);
diff --git a/core/src/main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java b/core/src/main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java
index 8f244459b..5258d5428 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/JaninoRexCompiler.java
@@ -199,8 +199,9 @@ public JaninoRexCompiler(RexBuilder rexBuilder) {
 static Scalar.Producer getScalar(ClassDeclaration expr, String s)
 throws CompileException, IOException {
 ICompilerFactory compilerFactory;
+ final ClassLoader classLoader = JaninoRexCompiler.class.getClassLoader();
 try {
- compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
+ compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(classLoader);
 } catch (Exception e) {
 throw new IllegalStateException(
 "Unable to instantiate java compiler", e);
@@ -208,7 +209,7 @@ public JaninoRexCompiler(RexBuilder rexBuilder) {
 IClassBodyEvaluator cbe = compilerFactory.newClassBodyEvaluator();
 cbe.setClassName(expr.name);
 cbe.setImplementedInterfaces(new Class[] \{Scalar.Producer.class});
- cbe.setParentClassLoader(JaninoRexCompiler.class.getClassLoader());
+ cbe.setParentClassLoader(classLoader);
 if (CalciteSystemProperty.DEBUG.value()) {
 // Add line numbers to the generated janino class
 cbe.setDebuggingInformation(true, true, true);
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java b/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
index 76106c938..a4c31e612 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
@@ -423,15 +423,16 @@ private static StringBuilder paramList(StringBuilder buff, Method method) {
 String classBody, MetadataDef<M> def,
 List<Object> argList) throws CompileException, IOException {
 final ICompilerFactory compilerFactory;
+ final ClassLoader classLoader = JaninoRexCompiler.class.getClassLoader();
 try {
- compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
+ compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(classLoader);
 } catch (Exception e) {
 throw new IllegalStateException(
 "Unable to instantiate java compiler", e);
 }
 
 final ISimpleCompiler compiler = compilerFactory.newSimpleCompiler();
- compiler.setParentClassLoader(JaninoRexCompiler.class.getClassLoader());
+ compiler.setParentClassLoader(classLoader);
 
 final String s = "public final class " + className
 + " implements " + def.handlerClass.getCanonicalName() + " {\n"
diff --git a/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java b/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
index 001a0bf16..d4ca4b3ae 100644
--- a/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
+++ b/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
@@ -19,10 +19,10 @@
 import org.apache.calcite.config.CalciteSystemProperty;
 
 import org.checkerframework.checker.nullness.qual.Nullable;
+import org.codehaus.commons.compiler.util.resource.MapResourceFinder;
+import org.codehaus.commons.compiler.util.resource.ResourceFinder;
 import org.codehaus.janino.JavaSourceClassLoader;
 import org.codehaus.janino.util.ClassFile;
-import org.codehaus.janino.util.resource.MapResourceFinder;
-import org.codehaus.janino.util.resource.ResourceFinder;
 
 import java.io.File;
 import java.io.FileOutputStream;
diff --git a/gradle.properties b/gradle.properties
index ac11bbcf0..7b8da5a11 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -106,7 +106,7 @@ hydromatic.tpcds.version=0.4
 innodb-java-reader.version=1.0.10
 jackson-databind.version=2.9.10.1
 jackson.version=2.10.0
-janino.version=3.0.11
+janino.version=3.1.4
 java-diff.version=1.1.2
 jcip-annotations.version=1.0-1
 jcommander.version=1.72
diff --git a/ubenchmark/src/jmh/java/org/apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java b/ubenchmark/src/jmh/java/org/apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java
index fe5ed0d2f..0807ebe19 100644
--- a/ubenchmark/src/jmh/java/org/apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java
+++ b/ubenchmark/src/jmh/java/org/apache/calcite/adapter/enumerable/CodeGenerationBenchmark.java
@@ -184,8 +184,9 @@ public void setup() {
 Expressions.toString(info.classExpr.memberDeclarations, "\n", false);
 
 ICompilerFactory compilerFactory;
+ final ClassLoader classLoader = EnumerableInterpretable.class.getClassLoader();
 try {
- compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
+ compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(classLoader);
 } catch (Exception e) {
 throw new IllegalStateException(
 "Unable to instantiate java compiler", e);
@@ -197,7 +198,7 @@ public void setup() {
 plan.getRowType().getFieldCount() == 1
 ? new Class[]\{Bindable.class, Typed.class}
 : new Class[]\{ArrayBindable.class});
- cbe.setParentClassLoader(EnumerableInterpretable.class.getClassLoader());
+ cbe.setParentClassLoader(classLoader);
 info.cbe = cbe;
 planInfos[i] = info;
 }
```

 

 

> UnitCompiler can not find required class information.
> -----------------------------------------------------
>
>                 Key: CALCITE-3745
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3745
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.21.0
>         Environment:  
> stacktrace:
> {code:java}
> Caused by: org.codehaus.commons.compiler.CompileException: Line 687, Column 40: Cannot determine simple type name "com"Caused by: org.codehaus.commons.compiler.CompileException: Line 687, Column 40: Cannot determine simple type name "com" at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:12124) at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6746) at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6507) at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6520) at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6520) at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6520) at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6520) at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6520) at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6520) at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:6486) at org.codehaus.janino.UnitCompiler.access$13800(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$21$1.visitReferenceType(UnitCompiler.java:6394) at org.codehaus.janino.UnitCompiler$21$1.visitReferenceType(UnitCompiler.java:6389) at org.codehaus.janino.Java$ReferenceType.accept(Java.java:3917) at org.codehaus.janino.UnitCompiler$21.visitType(UnitCompiler.java:6389) at org.codehaus.janino.UnitCompiler$21.visitType(UnitCompiler.java:6382) at org.codehaus.janino.Java$ReferenceType.accept(Java.java:3916) at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:6382) at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:7034) at org.codehaus.janino.UnitCompiler.access$16900(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$21$2.visitNewClassInstance(UnitCompiler.java:6442) at org.codehaus.janino.UnitCompiler$21$2.visitNewClassInstance(UnitCompiler.java:6403) at org.codehaus.janino.Java$NewClassInstance.accept(Java.java:5179) at org.codehaus.janino.UnitCompiler$21.visitRvalue(UnitCompiler.java:6403) at org.codehaus.janino.UnitCompiler$21.visitRvalue(UnitCompiler.java:6382) at org.codehaus.janino.Java$Rvalue.accept(Java.java:4105) at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:6382) at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:8939) at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:5060) at org.codehaus.janino.UnitCompiler.access$9100(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$16.visitMethodInvocation(UnitCompiler.java:4421) at org.codehaus.janino.UnitCompiler$16.visitMethodInvocation(UnitCompiler.java:4394) at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:5062) at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:4394) at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:5575) at org.codehaus.janino.UnitCompiler.compileBoolean2(UnitCompiler.java:4147) at org.codehaus.janino.UnitCompiler.access$6600(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$14.visitBinaryOperation(UnitCompiler.java:3955) at org.codehaus.janino.UnitCompiler$14.visitBinaryOperation(UnitCompiler.java:3933) at org.codehaus.janino.Java$BinaryOperation.accept(Java.java:4853) at org.codehaus.janino.UnitCompiler.compileBoolean(UnitCompiler.java:3933) at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:4709) at org.codehaus.janino.UnitCompiler.access$8800(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$16.visitConditionalExpression(UnitCompiler.java:4418) at org.codehaus.janino.UnitCompiler$16.visitConditionalExpression(UnitCompiler.java:4394) at org.codehaus.janino.Java$ConditionalExpression.accept(Java.java:4504) at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:4394) at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:5575) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2580) at org.codehaus.janino.UnitCompiler.access$2700(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$6.visitLocalVariableDeclarationStatement(UnitCompiler.java:1503) at org.codehaus.janino.UnitCompiler$6.visitLocalVariableDeclarationStatement(UnitCompiler.java:1487) at org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.java:3511) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1487) at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1567) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:3388) at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1357) at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1330) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:822) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:981) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:951) at org.codehaus.janino.UnitCompiler.access$200(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$2.visitAnonymousClassDeclaration(UnitCompiler.java:409) at org.codehaus.janino.UnitCompiler$2.visitAnonymousClassDeclaration(UnitCompiler.java:406) at org.codehaus.janino.Java$AnonymousClassDeclaration.accept(Java.java:1149) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:406) at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:5422) at org.codehaus.janino.UnitCompiler.access$9500(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$16.visitNewAnonymousClassInstance(UnitCompiler.java:4430) at org.codehaus.janino.UnitCompiler$16.visitNewAnonymousClassInstance(UnitCompiler.java:4394) at org.codehaus.janino.Java$NewAnonymousClassInstance.accept(Java.java:5227) at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:4394) at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:5575) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2649) at org.codehaus.janino.UnitCompiler.access$2800(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$6.visitReturnStatement(UnitCompiler.java:1504) at org.codehaus.janino.UnitCompiler$6.visitReturnStatement(UnitCompiler.java:1487) at org.codehaus.janino.Java$ReturnStatement.accept(Java.java:3552) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1487) at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1567) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:3388) at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1357) at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1330) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:822) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:981) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:951) at org.codehaus.janino.UnitCompiler.access$200(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$2.visitAnonymousClassDeclaration(UnitCompiler.java:409) at org.codehaus.janino.UnitCompiler$2.visitAnonymousClassDeclaration(UnitCompiler.java:406) at org.codehaus.janino.Java$AnonymousClassDeclaration.accept(Java.java:1149) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:406) at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:5422) at org.codehaus.janino.UnitCompiler.access$9500(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$16.visitNewAnonymousClassInstance(UnitCompiler.java:4430) at org.codehaus.janino.UnitCompiler$16.visitNewAnonymousClassInstance(UnitCompiler.java:4394) at org.codehaus.janino.Java$NewAnonymousClassInstance.accept(Java.java:5227) at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:4394) at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:5575) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2580) at org.codehaus.janino.UnitCompiler.access$2700(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$6.visitLocalVariableDeclarationStatement(UnitCompiler.java:1503) at org.codehaus.janino.UnitCompiler$6.visitLocalVariableDeclarationStatement(UnitCompiler.java:1487) at org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.java:3511) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1487) at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1567) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:3388) at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1357) at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1330) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:822) at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:432) at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:215) at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:411) at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:406) at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1414) at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:406) at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:378) at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:237) at org.codehaus.janino.SimpleCompiler.compileToClassLoader(SimpleCompiler.java:465) at org.codehaus.janino.ClassBodyEvaluator.compileToClass(ClassBodyEvaluator.java:313) at org.codehaus.janino.ClassBodyEvaluator.cook(ClassBodyEvaluator.java:235) at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:207) at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:50) at org.codehaus.janino.ClassBodyEvaluator.createInstance(ClassBodyEvaluator.java:347)
> {code}
>            Reporter: SHEN KAI
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 3h 40m
>  Remaining Estimate: 0h
>
> calcite uses specific classloader in  Unitcompiler, Usually is the launcher's default class loader. If user run sql with UDF, and the UDF class is loaded by a child classloader,  calcite's janino compiler throw a CompileException error.
> can calcite uses Thread.currentThread().getContextClassloader() to get the classloader in compiler? 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)