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

Universal availability check for an interactive console with JDK >= 22 support #4178

Merged
merged 2 commits into from
Dec 27, 2024

Conversation

nartamonov
Copy link
Contributor

JDK 22 introduced some changes to the method 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.

Mill assumes the old behavior of System.console and use System.console() != null to check if we have interactive console, causing issue like #4161.

This PR added universal availability check for an interactive console, compatible with JDK < 22 and later.

SBT made similar changes in sbt/sbt#7843.

Closes #4161

@nartamonov nartamonov marked this pull request as draft December 25, 2024 14:56
@nartamonov nartamonov marked this pull request as ready for review December 25, 2024 16:05
@nartamonov
Copy link
Contributor Author

A few tests fail, don't know why... it seems to me they do not relate to the changes.

@lihaoyi
Copy link
Member

lihaoyi commented Dec 25, 2024

@nartamonov the docjar issues look real, the rest are flakes

@nartamonov
Copy link
Contributor Author

nartamonov commented Dec 26, 2024

@nartamonov the docjar issues look real, the rest are flakes

@lihaoyi Well I fixed javadoc issues. As far as I can see, there are only issues with tests.

@lihaoyi
Copy link
Member

lihaoyi commented Dec 26, 2024

Thanks! Yes we have been having flakiness issues in CI lately, I'll kick them a few times until they turn green

@lihaoyi lihaoyi merged commit edc3b54 into com-lihaoyi:main Dec 27, 2024
25 of 26 checks passed
@lefou lefou added this to the 0.12.5 milestone Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing projects fails on VSCode and IntelliJ on Windows
3 participants