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

SBT console "swallow" keypresses on JDK 22 and Windows 10 #7580

Open
nartamonov opened this issue Jun 13, 2024 · 11 comments
Open

SBT console "swallow" keypresses on JDK 22 and Windows 10 #7580

nartamonov opened this issue Jun 13, 2024 · 11 comments
Assignees
Labels
area/jdk_x jdk 9, 10, 11, 17 etc area/shell sbt shell and slash syntax related issues Bug

Comments

@nartamonov
Copy link

steps

Install Eclipse Temurin 22.0.1+8 in Windows 10. Run the SBT console for any project from the cmd.exe terminal. Then try to work in the console: enter different commands, try to insert into the console text from the clipboard.

problem

The SBT console "swallows" (skips) certain key strokes: symbols do not appear in the console. Also does not work properly copy and paste.

cause and workaround

The problem seems to be that JDK 22 has changed the behavior of System.console():

In JDK 22, System.console() has been changed to return a Console with enhanced editing features that improve the experience of programs that use the Console API. In addition, System.console() now returns a Console object when the standard streams are redirected or connected to a virtual terminal. Prior to JDK 22, System.console() instead returned null for these cases. This change may impact code that checks the return from System.console() to test if the JVM is connected to a terminal. If required, the -Djdk.console=java.base flag will restore the old behavior where the console is only returned when it is connected to a terminal. Starting JDK 22, one could also use the new Console.isTerminal() method to test if the console is connected to a terminal.

Setting the -Djdk.console=java.base option in .jvmopts solves the problem: SBT starts working normally.

@nartamonov nartamonov added the Bug label Jun 13, 2024
@eed3si9n eed3si9n added the area/jdk_x jdk 9, 10, 11, 17 etc label Jun 13, 2024
@Friendseeker Friendseeker self-assigned this Oct 27, 2024
@Friendseeker Friendseeker added the area/shell sbt shell and slash syntax related issues label Oct 27, 2024
@Friendseeker
Copy link
Member

Friendseeker commented Oct 28, 2024

image

image

Not reproducible on sbt 1.10.4

Feel free to leave a comment & reopen the issue if the issue is still reproducible on your end

@azdrojowa123
Copy link
Contributor

azdrojowa123 commented Dec 9, 2024

@Friendseeker
Hello,
I'm working on resolving this issue in the sbt shell within the Scala plugin and this has caused me to look at this issue one the sbt side.
I attached 2 vides - the first one is with JDK 17 and eveything works smoothly there. I can type letters very quickly and everything is written fine, copying also works without problems . The second video is with JDK 22. Although, if I write letters very slowly I can write "compile" correctly, but copying is totally broken. At the end of the video, when I copied "compile" and "cp" was displayed I had to press enter about 10 times before it was actually done.

jdk22.mp4
jdk17.mp4

@Friendseeker Friendseeker reopened this Dec 9, 2024
@Friendseeker
Copy link
Member

@Friendseeker Hello, I'm working on resolving this issue in the sbt shell within the Scala plugin and this has caused me to look at this issue one the sbt side. I attached 2 vides - the first one is with JDK 17 and eveything works smoothly there. I can type letters very quickly and everything is written fine, copying also works without problems . The second video is with JDK 22. Although, if I write letters very slowly I can write "compile" correctly, but copying is totally broken. At the end of the video, when I copied "compile" and "cp" was displayed I had to press enter about 10 times before it was actually done.

jdk22.mp4

jdk17.mp4

Not reproduce on Mac, so it is a Windows only issue...

Screen.Recording.2024-12-20.at.2.28.59.AM.mov

I wonder if this issue is indeed caused by sbt's windows special handlings, or maybe some upstream dep of sbt.

Thanks for looking into this issue!

@Friendseeker
Copy link
Member

Might indeed be upstream issue?

jline/jline3#952 (comment)

@Friendseeker
Copy link
Member

Shall test if -Djdk.console=java.base workaround still works. In worst case I guess adding the flag to sbt windows launcher bat script is always an option...

@azdrojowa123
Copy link
Contributor

azdrojowa123 commented Dec 20, 2024

so it is a Windows only issue...

yes I think it's only a windows issue

@Friendseeker
Copy link
Member

Friendseeker commented Dec 20, 2024

Also cannot reproduce the issue with Windows Terminal & Git Bash. I spam copied compile and none of the keystrokes are eaten.

image

@Friendseeker
Copy link
Member

Cannot reproduce the issue on Windows Terminal & Windows Powershell either. I guess it really is just CMD?

image

@Friendseeker
Copy link
Member

I cannot reproduce the issue with cmd.exe

image

@azdrojowa123 Maybe something in sbt 1.10.6 had fixed it? Such as #7876

@nartamonov
Copy link
Author

Interesting... Just tried fresh SBT 1.10.7 with Eclipse Temurin 22.0.1 and 23.0.1. The issue is reproduced with JDK 22.0.1, but everything works fine with JDK 23.0.1.

@Friendseeker
Copy link
Member

Interesting... Just tried fresh SBT 1.10.7 with Eclipse Temurin 22.0.1 and 23.0.1. The issue is reproduced with JDK 22.0.1, but everything works fine with JDK 23.0.1.

Cursed. I tested locally and can confirm that the issue is JDK 22 only, not reproducible on JDK 23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/jdk_x jdk 9, 10, 11, 17 etc area/shell sbt shell and slash syntax related issues Bug
Projects
None yet
Development

No branches or pull requests

4 participants