-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Console color only if JDK 22 says isConsole #10751
Conversation
@som-snytt thank you! mind submitting a 2.12.x backport? |
@SethTisue did it work? your wish or even idle supposition is my command. |
@som-snytt oh we're not done yet, there are still test failures at https://github.com/scala/scala/actions/runs/8665032593 |
// false if JDK 22 and the system console says !isTerminal | ||
def consoleIsTerminal: Boolean = { | ||
def isTerminal: Boolean = | ||
try classOf[java.io.Console].getMethod("isTerminal", null).invoke(System.console).asInstanceOf[Boolean] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my macOS
➜ sandbox java -version
openjdk version "22" 2024-03-19
OpenJDK Runtime Environment Temurin-22+36 (build 22+36)
OpenJDK 64-Bit Server VM Temurin-22+36 (build 22+36, mixed mode)
➜ sandbox s
> scala repl -S 2.13 -cp .
Welcome to Scala 2.13.13 (OpenJDK 64-Bit Server VM, Java 22).
Type in expressions for evaluation. Or try :help.
scala> classOf[java.io.Console].getMethod("isTerminal", null)
java.lang.NoSuchMethodException: java.io.Console.isTerminal(null)
at java.base/java.lang.Class.getMethod(Class.java:2405)
... 30 elided
@@ -38,7 +39,7 @@ object ShellConfig { | |||
val batchText: String = if (settings.execute.isSetByUser) settings.execute.value else "" | |||
val batchMode: Boolean = batchText.nonEmpty | |||
val doCompletion: Boolean = !(settings.noCompletion.value || batchMode) | |||
val haveInteractiveConsole: Boolean = !settings.Xnojline.value | |||
override val haveInteractiveConsole: Boolean = super.haveInteractiveConsole && !settings.Xnojline.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke JLine support for me - it needs to be a lazy val due to safe init.
Reverted in #10758
Color output also depends on isConsole on jdk 22