Github user lianhuiwang commented on a diff in the pull request:
https://github.com/apache/spark/pull/6898#discussion_r32811387
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
---
@@ -241,12 +236,19 @@ abstract class CodeGenerator[InType <: AnyRef,
OutType <: AnyRef] extends Loggin
*/
protected def compile(code: String): Class[_] = {
val startTime = System.nanoTime()
+ // Current class loader may be ExecutorClassLoader, which will cause
fail to find
+ // class in java.lang. It's also slow, use the default JVM class
loader.
+ val currentThread = Thread.currentThread()
+ val oldClassLoader = currentThread.getContextClassLoader
+ currentThread.setContextClassLoader(getClass.getClassLoader)
--- End diff --
i think we do not need to set setContextClassLoader. and we can set
ClassBodyEvaluator's classLoader. code is:
val classBodyEval =new ClassBodyEvaluator()
classBodyEval.setParentClassLoader(getClass.getClassLoader)
classBodyEval.cook(code)
classBodyEval.getClazz()
some information:
http://janino.net/javadoc/org/codehaus/janino/ClassBodyEvaluator.html,
https://github.com/codehaus/janino/blob/6e61d5b71b4e8682a3497cb1e33a005bee4ca0a2/janino/src/org/codehaus/janino/SimpleCompiler.java#L172
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]