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

Adapt new behavior of System.console() since JDK22 #69

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Eng-Fouad
Copy link

Resolves #68

// Console.isTerminal() was introduced in Java 22
private static boolean isTerminal(Console console) {
try {
Method isTerminal = Console.class.getMethod("isTerminal");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's worth switching to a multi-versioned jar instead of relying on reflection + exception?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @stalep

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, instead of reflection could we check if Runtime.version() > 21 ?
Tbh, I'm not sure what's the "best" solution here, I'm open for anything. This method is usually not called more than once anyway...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the new method isTerminal won't compile on older JDKs (<= 21).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsmet @stalep Submitted an alternative PR that uses "multi-release jar" feature: #70

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.

Adapt new behavior of System.console() since JDK22
3 participants