Skip to content
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

[SPARK-27121][REPL] Resolve Scala compiler failure for Java 9+ in REPL #24239

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 7 additions & 17 deletions repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
Expand Up @@ -18,9 +18,7 @@
package org.apache.spark.repl

import java.io._
import java.net.URLClassLoader

import scala.collection.mutable.ArrayBuffer
import scala.tools.nsc.interpreter.SimpleReader

import org.apache.log4j.{Level, LogManager}
Expand All @@ -34,33 +32,25 @@ class ReplSuite extends SparkFunSuite {
def runInterpreter(master: String, input: String): String = {
val CONF_EXECUTOR_CLASSPATH = "spark.executor.extraClassPath"

val in = new BufferedReader(new StringReader(input + "\n"))
val out = new StringWriter()
val cl = getClass.getClassLoader
var paths = new ArrayBuffer[String]
if (cl.isInstanceOf[URLClassLoader]) {
val urlLoader = cl.asInstanceOf[URLClassLoader]
for (url <- urlLoader.getURLs) {
if (url.getProtocol == "file") {
paths += url.getFile
}
}
}
val classpath = paths.map(new File(_).getAbsolutePath).mkString(File.pathSeparator)

val oldExecutorClasspath = System.getProperty(CONF_EXECUTOR_CLASSPATH)
val classpath = System.getProperty("java.class.path")
System.setProperty(CONF_EXECUTOR_CLASSPATH, classpath)

Main.sparkContext = null
Main.sparkSession = null // causes recreation of SparkContext for each test.
Main.conf.set("spark.master", master)

val in = new BufferedReader(new StringReader(input + "\n"))
val out = new StringWriter()
Main.doMain(Array("-classpath", classpath), new SparkILoop(in, new PrintWriter(out)))

if (oldExecutorClasspath != null) {
System.setProperty(CONF_EXECUTOR_CLASSPATH, oldExecutorClasspath)
} else {
System.clearProperty(CONF_EXECUTOR_CLASSPATH)
}
return out.toString

out.toString
}

// Simulate the paste mode in Scala REPL.
Expand Down
17 changes: 2 additions & 15 deletions repl/src/test/scala/org/apache/spark/repl/SingletonReplSuite.scala
Expand Up @@ -18,9 +18,6 @@
package org.apache.spark.repl

import java.io._
import java.net.URLClassLoader

import scala.collection.mutable.ArrayBuffer

import org.apache.commons.lang3.StringEscapeUtils

Expand All @@ -42,19 +39,9 @@ class SingletonReplSuite extends SparkFunSuite {
override def beforeAll(): Unit = {
super.beforeAll()

val cl = getClass.getClassLoader
var paths = new ArrayBuffer[String]
if (cl.isInstanceOf[URLClassLoader]) {
val urlLoader = cl.asInstanceOf[URLClassLoader]
for (url <- urlLoader.getURLs) {
if (url.getProtocol == "file") {
paths += url.getFile
}
}
}
val classpath = paths.map(new File(_).getAbsolutePath).mkString(File.pathSeparator)

val classpath = System.getProperty("java.class.path")
System.setProperty(CONF_EXECUTOR_CLASSPATH, classpath)

Main.conf.set("spark.master", "local-cluster[2,1,1024]")
val interp = new SparkILoop(
new BufferedReader(new InputStreamReader(new PipedInputStream(in))),
Expand Down