Skip to content

Commit 1bde4c5

Browse files
authored
Add org.jline as module to component directory (#8496)
Add `jline` module to the distribution so that our REPL is usable again. # Important Notes - No more: "WARNING: Unable to create a system terminal, creating a dumb terminal " warning when starting REPL - Arrow keys works as expected in REPL - Back search (the default shortcut `CTRL + R`) works as expected.
1 parent ab938e8 commit 1bde4c5

File tree

1 file changed

+8
-0
lines changed
  • engine/runner/src/main/scala/org/enso/runner

1 file changed

+8
-0
lines changed

engine/runner/src/main/scala/org/enso/runner/Repl.scala

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ case class SimpleReplIO(in: InputStream, out: OutputStream) extends ReplIO {
9696
/** An implementation of [[ReplIO]] using system terminal capabilities.
9797
*/
9898
case class TerminalIO(historyFilePath: Path) extends ReplIO {
99+
// jline uses the class loader from `Thread.currentThread().getContextClassLoader()` to
100+
// load services. We need to override the context class loader to be `IsolatedClassLoader`
101+
// from the runner.jar class loader.
102+
private val prevClassLoader = Thread.currentThread().getContextClassLoader
103+
Thread
104+
.currentThread()
105+
.setContextClassLoader(classOf[TerminalIO].getClassLoader)
99106
private val terminal: Terminal =
100107
TerminalBuilder.builder().system(true).build()
101108
private val parser: DefaultParser = new DefaultParser()
@@ -109,6 +116,7 @@ case class TerminalIO(historyFilePath: Path) extends ReplIO {
109116
.history(history)
110117
.terminal(terminal)
111118
.build()
119+
Thread.currentThread().setContextClassLoader(prevClassLoader)
112120

113121
Runtime.getRuntime.addShutdownHook(new Thread() {
114122
override def run(): Unit = {

0 commit comments

Comments
 (0)