-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-25235] [SHELL] Merge the REPL code in Scala 2.11 and 2.12 branches #22246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Ping @srowen |
|
Test build #95302 has finished for PR 22246 at commit
|
|
If it works, great! You can then remove the hacks in the POM to support 2.11 vs 2.12 code? I wonder if 2.12 will compile the other two classes found in the 2.11 tree. |
|
@viirya The reflection trick we use in @srowen The other two files in 2.11 can not be compiled in 2.12 . I removed the POM hack as well. Thanks for pointing out. |
|
Oh, but if there's on tree for both versions, and it has files that 2.11 needs but 2.12 can't compile, won't it fail? Not sure about the NSME error up there, I haven't seen it. |
|
|
|
I understand, you still need the extra source files in a separate tree just for 2.11. |
|
Yes. But we can remove the code in 2.12, and this can also fix the printing order issue in 2.12. I don't know why we get some reflection error in tests. It works in command line. I will do some debugging tonight. |
| if (isScala2_11) { | ||
| val loader = Utils.classForName("scala.reflect.internal.util.ScalaClassLoader$") | ||
| .getDeclaredField("MODULE$") | ||
| .get(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viirya Out of my curiosity, since it's a static method, in theory, in the invoke, the first arg should be null. Why do you put the loader in? Also, this doesn't work in tests, and we get the method not found exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it is a static method in Scala, it will be compiled to a non-static method in Java class. This class has a static member of the class type. The access of all Scala static methods are through the static member.
|
Test build #95304 has finished for PR 22246 at commit
|
Yeah, it seems due to classloader. After changed to Spark classloader, the tests were passed locally. Let's see if Jenkins tests pass too. |
|
Test build #95324 has finished for PR 22246 at commit
|
|
retest this please. |
|
Test build #95333 has finished for PR 22246 at commit
|
|
retest this please. |
|
Test build #95348 has finished for PR 22246 at commit
|
|
retest this please |
| settings.classpath append addedClasspath | ||
| } | ||
| intp = Utils.classForNameFromSpark("org.apache.spark.repl.SparkILoopInterpreter") | ||
| .getDeclaredConstructor(Seq(classOf[Settings], classOf[JPrintWriter]): _*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To summarize the classLoader issue here, classOf[Settings] will use the classloader of the object of SparkILoop, and Utils.classForName will use the classloader of the current running thread which can lead to mismatching.
I think using Utils.classForNameFromSpark is dangerous since there is no guaranteed that this will use the classloader of this object which is used in classOf[Settings].
I will use Class.ofName to ensure the consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
|
Test build #95360 has finished for PR 22246 at commit
|
|
Test build #95383 has finished for PR 22246 at commit
|
|
Test build #95381 has finished for PR 22246 at commit
|
|
LGTM |
|
Test build #95393 has finished for PR 22246 at commit
|
|
Thanks all for reviewing. Merged into master. |
What changes were proposed in this pull request?
Using some reflection tricks to merge Scala 2.11 and 2.12 codebase.
How was this patch tested?
Existing tests.