[1.x] Fix Scala 3.9.x console crash by loading all JLine jars together (#9564)

This commit is contained in:
Piotr Chabelski
2026-08-07 04:52:20 -04:00
committed by GitHub
parent fa5f2f16e5
commit 76620536ee
3 changed files with 20 additions and 1 deletions
@@ -66,8 +66,11 @@ public final class MetaBuildLoader extends URLClassLoader {
* library.
*/
public static MetaBuildLoader makeLoader(final AppProvider appProvider) throws IOException {
// Every org.jline artifact must live in this tier together. The REPL's ScalaInstance
// loader is parented to it, so a partial match leaves the REPL running one JLine
// version's reader against another's terminal (#9317, #8294).
final String jlineJars =
"jline-?[0-9.]+-sbt-.*|jline-terminal(-(jni))?-[0-9.]+|jline-native-[0-9.]+";
"jline-?[0-9.]+-sbt-.*|jline-(terminal(-jni)?|native|reader|builtins|style)-[0-9.]+";
final String testInterfaceJars = "test-interface(-.*)?";
final String compilerInterfaceJars = "compiler-interface(-.*)?";
final String utilInterfaceJars = "util-interface(-.*)?";
@@ -0,0 +1,14 @@
scalaVersion := "3.9.0-RC4"
lazy val markerFile = settingKey[java.io.File]("marker file written by the console REPL once it starts")
markerFile := target.value / "console-jline-ok"
console / initialCommands := {
val path = markerFile.value.getAbsolutePath.replace("\\", "\\\\")
// Scala 3.9 ships JLine 4 while sbt 1.x ships JLine 3. A partial match in
// MetaBuildLoader's JLine tier used to leave the REPL running jline-reader 4.x
// against jline-terminal 3.x, which throws NoSuchMethodError before the prompt
// (#9317). The marker is only written if the REPL actually starts.
s"""java.nio.file.Files.write(java.nio.file.Paths.get("$path"), Array.emptyByteArray)"""
}
@@ -0,0 +1,2 @@
> console
$ exists target/console-jline-ok