Skip to content

Commit ffd0de4

Browse files
committed
Add a warning when using the ExecTerminalProvider on recent JDKs
1 parent 1ac766f commit ffd0de4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

terminal/src/main/java/org/jline/terminal/impl/exec/ExecTerminalProvider.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@
2525
import org.jline.terminal.spi.Pty;
2626
import org.jline.terminal.spi.TerminalProvider;
2727
import org.jline.utils.ExecHelper;
28+
import org.jline.utils.Log;
2829
import org.jline.utils.OSUtils;
2930

3031
public class ExecTerminalProvider implements TerminalProvider {
3132

33+
private static boolean warned;
34+
3235
public String name() {
3336
return "exec";
3437
}
@@ -142,11 +145,21 @@ public String systemStreamName(Stream stream) {
142145
return result.trim();
143146
}
144147
} catch (Throwable t) {
148+
if ("java.lang.reflect.InaccessibleObjectException"
149+
.equals(t.getClass().getName())
150+
&& !warned) {
151+
Log.warn(
152+
"The ExecTerminalProvider requires the JVM options: '--add-opens java.base/java.lang=ALL-UNNAMED'");
153+
warned = true;
154+
}
145155
// ignore
146156
}
147157
return null;
148158
}
149159

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

0 commit comments

Comments
 (0)