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 #70

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions readline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
</manifest>
<manifestEntries>
<Automatic-Module-Name>${javaModuleName}</Automatic-Module-Name>
<Multi-Release>true</Multi-Release>
</manifestEntries>
<index>true</index>
</archive>
Expand All @@ -124,6 +125,32 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile-java-8</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</execution>
<execution>
<id>compile-java-22</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>22</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java22</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ else if (OSUtils.IS_WINDOWS) {

private Terminal createWindowsTerminal(String name) throws IOException {
try {
//if console != null its a native terminal, not redirects etc
if(System.console() != null)
// a native terminal, not redirects etc
if(TerminalChecker.isTerminalAvailable())
return new WinSysTerminal(name, nativeSignals);
else {
return new WinExternalTerminal(name, type, (in == null) ? System.in : in,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.aesh.readline.terminal;

public class TerminalChecker {

public static boolean isTerminalAvailable() {
return System.console() != null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.aesh.readline.terminal;

public class TerminalChecker {

public static boolean isTerminalAvailable() {
var console = System.console();
return console != null && console.isTerminal();
}
}