RFR JDK-8131023: JShell: System.in does not work

Jan Lahoda jan.lahoda at oracle.com
Thu Aug 25 15:23:35 UTC 2016



Langtools webrev:

JDK repository webrev:


Currently jshell forwards output from the agent to the main process. 
With this patch, the input is also forwarded from the main process to 
the agent. InputStream.read() is only called in the main process if it 
has been called on the agent side; this is achieved by using an 
artificial OutputStream in the agent->main process direction. On the 
agent side, when an input is requested, a character is written to the 
corresponding artificial OutputStream, the main process is about that, 
reads from the actual input and sends the data back to the agent.

In the tool, jline is used to actually read the input, as System.in is 
switched in the raw mode. This requires a tweak in jline, to detect the 
proper column on which the editing starts, to cover requests like:

System.err.print("Prompt: "); System.err.flush(); System.in.read();

Without the tweak, the line editor wouldn't unfortunately know about the 
text written to the console (for supported terminals, at least). (This 
tweak may be useful in any case for complex prompts that use escape 
sequences; also for jjs.)

An alternative would be to try to switch jline off while reading the 
user's input. The advantage of using jline is that it allows to detect 

Any feedback is welcome!


More information about the kulla-dev mailing list