JDK-8191640 : [Windows] JShell Defectively Wraps Lines And Mangles Input in JDK9
  • Type: Bug
  • Component: tools
  • Sub-Component: jshell
  • Affected Version: 9,9.0.1,10
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows
  • CPU: x86_64
  • Submitted: 2017-11-20
  • Updated: 2017-12-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbd_minorUnresolved
Description
FULL PRODUCT VERSION :
java version "9"
Java(TM) SE Runtime Environment (build 9+179)
Java HotSpot(TM) 64-Bit Server VM (build 9+179, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

EXTRA RELEVANT SYSTEM CONFIGURATION :
The "Screen Buffer Size Width" property of the Windows command shell is configured to its maximum value of 9999

A DESCRIPTION OF THE PROBLEM :
When using JShell, the "Screen Buffer Size Width" property of the Windows command shell is ignored. As a result, JShell wraps long lines of input back on themselves. When a line wraps, JShell doesn't create a new line. Instead, the JShell cursor doubles back to the beginning of the same line and overwrites characters in that line.

You can also observe the defect in action in a screen recording I uploaded.[1]

JShell appears to be using the rightmost dimension of the actual width of the window as its cue to wrap a line; ignoring the Windows command shell's "Screen Buffer Size Width" property. That property's sole purpose in life is to explicitly prevent wrapping and allow long lines up to a maximum of 9999 characters.

[1] https://imgur.com/Pqvoc2G  (A short screen recording showing the defect in action)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Type "Windows + R" to launch the "Run" dialog.
2. Type "cmd" into the "Open" field shown in the "Run" dialog.
3. When the command shell opens, click on the "C:\ " command prompt icon located in the top-left corner of the command shell window. A context menu is displayed.
4. Select the "Properties" item in the context menu. A tabbed "Properties" panel is displayed.
5. Navigate to the "Layout" tab of the "Properties" panel.
6. In the "Screen Buffer Size" section of the "Layout" tab, set the value of the "Width" property to 9999 (the maximum allowed).
7. Click "OK" to accept and activate the new "Properties" configuration.
8. Still in the cmd shell, enter "jshell" to start the JDK 9 REPL shell.
9. At the JShell prompt, type any long line text that has a character length longer than the width of the JShell window, but fewer characters than the width of the "Screen Buffer Size Width" property configured earlier. For example [1]...
------------------------------------------------------------------------------------
jshell> Long.parseLong( "0110100001110101101010001000011000000001111", 2) + Integer.parseInt("00001111001110001101111100011101", 2) + Long.parseLong("00111111011110000111100001001111",2);

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



[1] https://imgur.com/Pqvoc2G (A short screen recording showing the defect in action)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Because the "Screen Buffer Size Width" property was configured with the maximum-allowed value of 9999, JShell should honor that configuration. Every character of a long line of input that is typed onto one line, should all appear on that one line; as it is being typed.
ACTUAL -
When input typed into JShell reaches the rightmost edge of the JShell screen, JShell then incorrectly repositions the cursor at the beginning of the same input line. Input that is currently being typed onto that line, overwrites (visually obscures) the input that was previously typed onto that same line.

JShell appears to use the dimension of the rightmost edge of the command window as its cue to wrap to a new line. However it doesn't even "wrap" to an actual new line. Instead, it doubles back to the beginning of the same input line. 

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
This issue is reproducible only on windows in jdk 9 and 10 == Wrapping of line and Mangles Input observed == Step 1: Long.parseLong( "011", 2) + Integer.parseInt("0000101", 2); //kjeepadding 0 and 1 in Long.parseLong( "011....) Step2 : once line width exceeds we can observe mangling of line like below ,2)ell> Long.parseLong( "0110100001110101101010001000011000000001111", 2) + Integer.parseInt("00" ==
21-11-2017