# HG changeset patch # User wenzelm # Date 1650533330 -7200 # Node ID d5041b68a2374a4a7965feb5b3794a68fa41e3b3 # Parent 400e325a54164c981a7d04dfd4f0bf027c10796e clarified signature; diff -r 400e325a5416 -r d5041b68a237 src/Pure/System/scala.scala --- 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 } } diff -r 400e325a5416 -r d5041b68a237 src/Tools/jEdit/jedit_main/scala_console.scala --- 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) =>