Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8174525 | 10 | Robert Field | P2 | Resolved | Fixed | b01 |
jshell> String s = "A!\rB!"
B!"=> "A!
jshell> String s = "A!\rFOOOOOOOOOOOOOOOOOO"
FOOOOOOOOOOOOOOOOOO"
It seems when printing Strings, \r is treated literally as a carriage
return signal to the shell, which means the next char in the string
is printed from the beginning of the current line.
I'm a bit torn: while it's nice that \n (or whichever is native) is
printed as a new line, maybe it's best (and least bug-prone) to simply
escape all control characters?
jshell> String s = "A!\nFOOOOOOOOOOOOOOOOOO"
s ==> "A!
FOOOOOOOOOOOOOOOOOO"
vs
jshell> String s = "A!\nFOOOOOOOOOOOOOOOOOO"
s ==> "A!\nFOOOOOOOOOOOOOOOOOO"
B!"=> "A!
jshell> String s = "A!\rFOOOOOOOOOOOOOOOOOO"
FOOOOOOOOOOOOOOOOOO"
It seems when printing Strings, \r is treated literally as a carriage
return signal to the shell, which means the next char in the string
is printed from the beginning of the current line.
I'm a bit torn: while it's nice that \n (or whichever is native) is
printed as a new line, maybe it's best (and least bug-prone) to simply
escape all control characters?
jshell> String s = "A!\nFOOOOOOOOOOOOOOOOOO"
s ==> "A!
FOOOOOOOOOOOOOOOOOO"
vs
jshell> String s = "A!\nFOOOOOOOOOOOOOOOOOO"
s ==> "A!\nFOOOOOOOOOOOOOOOOOO"
- backported by
-
JDK-8174525 JShell: control characters should be escaped in String values
-
- Resolved
-
- relates to
-
JDK-8133020 JShell API: special printing for arrays, Collection, Strings
-
- Closed
-