[jdk20] RFR: 8298425: System.console().readLine() hangs in jshell

Naoto Sato naoto at openjdk.org
Fri Dec 9 17:36:55 UTC 2022


On Fri, 9 Dec 2022 15:19:50 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> After https://bugs.openjdk.org/browse/JDK-8295803, JShell snippets like:
>> 
>> jshell> System.console().readLine()
>> 
>> 
>> hang, as the JLine console is used, and it cannot correctly read from the console while in the remote agent (due to input/output redirection setup for the agent). Until [JDK-8296454](https://bugs.openjdk.org/browse/JDK-8296454) is resolved, the JLine console should be disabled inside the remote agent.
>> 
>> As the default console requires an attached terminal, and there is no attached terminal inside the agent, `System.console()` should then return `null` inside the JShell's agent, which was the behavior before JDK-8295803.
>
> src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java line 62:
> 
>> 60:     public static void main(String[] args) throws Exception {
>> 61:         //disable System.console()
>> 62:         System.setProperty("jdk.console", "java.base");
> 
> It would probably be more robust to have set on the debuggee command line but what you have is okay, as Console just reads the property rather using the "save properties" from startup.

Thought of the same thing as Alan mentioned here, but I think it is OK too, as a temporary measure before JDK-8296454 is fixed.

-------------

PR: https://git.openjdk.org/jdk20/pull/11


More information about the kulla-dev mailing list