-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GR-48855] Test truffleruby on JDK latest
PullRequest: truffleruby/4027
- Loading branch information
Showing
7 changed files
with
117 additions
and
119 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/org/truffleruby/stdlib/readline/IsTTYHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 2.0, or | ||
* GNU General Public License version 2, or | ||
* GNU Lesser General Public License version 2.1. | ||
*/ | ||
package org.truffleruby.stdlib.readline; | ||
|
||
import java.io.Console; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
|
||
public final class IsTTYHelper { | ||
|
||
private static final Method IS_TERMINAL_METHOD = getIsTerminalMethod(); | ||
|
||
private static Method getIsTerminalMethod() { | ||
try { | ||
return Console.class.getMethod("isTerminal"); | ||
} catch (NoSuchMethodException e) { | ||
return null; | ||
} | ||
} | ||
|
||
public static boolean isTTY() { | ||
Console console = System.console(); | ||
if (console == null) { | ||
return false; | ||
} | ||
if (IS_TERMINAL_METHOD != null) { | ||
try { | ||
return (boolean) IS_TERMINAL_METHOD.invoke(console); | ||
} catch (IllegalAccessException | InvocationTargetException e) { | ||
throw new Error(e); | ||
} | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters