--- a/src/Pure/System/scala.scala Thu Apr 21 10:07:17 2022 +0200
+++ b/src/Pure/System/scala.scala Thu Apr 21 11:28:50 2022 +0200
@@ -82,7 +82,8 @@
object Compiler {
def context(
error: String => Unit = Exn.error,
- jar_dirs: List[JFile] = Nil
+ jar_dirs: List[JFile] = Nil,
+ class_loader: Option[ClassLoader] = None
): Context = {
def find_jars(dir: JFile): List[String] =
File.find_files(dir, file => file.getName.endsWith(".jar")).
@@ -92,23 +93,22 @@
settings.classpath.value =
(class_path() ::: jar_dirs.flatMap(find_jars)).mkString(JFile.pathSeparator)
- new Context(settings)
+ new Context(settings, class_loader)
}
def default_print_writer: PrintWriter =
new NewLinePrintWriter(new ConsoleWriter, true)
- class Context private [Compiler](val settings: GenericRunnerSettings) {
+ class Context private [Compiler](
+ val settings: GenericRunnerSettings,
+ val class_loader: Option[ClassLoader]
+ ) {
override def toString: String = settings.toString
- def interpreter(
- print_writer: PrintWriter = default_print_writer,
- class_loader: ClassLoader = null
- ): IMain = {
+ def interpreter(print_writer: PrintWriter = default_print_writer): IMain = {
new IMain(settings, new ReplReporterImpl(settings, print_writer)) {
override def parentClassLoader: ClassLoader =
- if (class_loader == null) super.parentClassLoader
- else class_loader
+ class_loader getOrElse super.parentClassLoader
}
}
--- a/src/Tools/jEdit/jedit_main/scala_console.scala Thu Apr 21 10:07:17 2022 +0200
+++ b/src/Tools/jEdit/jedit_main/scala_console.scala Thu Apr 21 11:28:50 2022 +0200
@@ -92,10 +92,11 @@
def interrupt(): Unit = running.change({ opt => opt.foreach(_.interrupt()); opt })
private val interp =
- Scala.Compiler.context(error = report_error, jar_dirs = JEdit_Lib.directories).
- interpreter(
- print_writer = new PrintWriter(console_writer, true),
- class_loader = new JARClassLoader)
+ Scala.Compiler.context(
+ error = report_error,
+ jar_dirs = JEdit_Lib.directories,
+ class_loader = Some(new JARClassLoader)).
+ interpreter(new PrintWriter(console_writer, true))
val thread: Consumer_Thread[Request] = Consumer_Thread.fork("Scala_Console") {
case Start(console) =>