Skip to content
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

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Apr 11, 2024

Reverted in #10758

Color output also depends on isConsole on jdk 22

@scala-jenkins scala-jenkins added this to the 2.13.15 milestone Apr 11, 2024
@som-snytt som-snytt marked this pull request as ready for review April 12, 2024 15:39
@SethTisue SethTisue modified the milestones: 2.13.15, 2.13.14 Apr 12, 2024
@SethTisue SethTisue merged commit b68ac48 into scala:2.13.x Apr 12, 2024
3 checks passed
@som-snytt som-snytt deleted the sd/867-jdk22-tests branch April 12, 2024 16:48
@SethTisue
Copy link
Member

@som-snytt thank you! mind submitting a 2.12.x backport?

@som-snytt
Copy link
Contributor Author

@SethTisue did it work? your wish or even idle supposition is my command.

@SethTisue
Copy link
Member

@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]
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants