Skip to content

Commit

Permalink
Add a warning when using the ExecTerminalProvider on recent JDKs
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Aug 1, 2023
1 parent 1ac766f commit ffd0de4
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
import org.jline.terminal.spi.Pty;
import org.jline.terminal.spi.TerminalProvider;
import org.jline.utils.ExecHelper;
import org.jline.utils.Log;
import org.jline.utils.OSUtils;

public class ExecTerminalProvider implements TerminalProvider {

private static boolean warned;

public String name() {
return "exec";
}
Expand Down Expand Up @@ -142,11 +145,21 @@ public String systemStreamName(Stream stream) {
return result.trim();
}
} catch (Throwable t) {
if ("java.lang.reflect.InaccessibleObjectException"
.equals(t.getClass().getName())
&& !warned) {
Log.warn(
"The ExecTerminalProvider requires the JVM options: '--add-opens java.base/java.lang=ALL-UNNAMED'");
warned = true;
}
// ignore
}
return null;
}

/**
* This requires --add-opens java.base/java.lang=ALL-UNNAMED
*/
private ProcessBuilder.Redirect getRedirect(FileDescriptor fd) throws ReflectiveOperationException {
// This is not really allowed, but this is the only way to redirect the output or error stream
// to the input. This is definitely not something you'd usually want to do, but in the case of
Expand Down

0 comments on commit ffd0de4

Please sign in to comment.