RFR: 8299829: In jshell, the output of "0".repeat(49999)+"2" ends with a '0'

Adam Sotona asotona at openjdk.org
Tue Jan 10 15:51:29 UTC 2023


"0".repeat(49999)+"2" correctly evaluates to a string with a terminating '2'. 
However, jshell outputs it with a terminating '0'.

Jshell provides double truncation of long Strings. 
One is performed in jdk.jshell.execution.ExecutionControlForwarder to fit into MAX_UTF_CHARS = 21844 (which is exactly the point where "2" disappears). 
Second truncation is performed in jdk.internal.jshell.tool.Feedback to fit presentation requirements. 
While ExecutionControlForwarder truncates right part of the String, Feedback truncated inner part in 2/3 and joins the parts with " ... ". 

Proposed patch fixes ExecutionControlForwarder to truncate long Strings the same way as Feedback, so the right part of any long String won't disappear and double or repeated truncation provides consistent results.

Please review :)

Thanks,
Adam

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

Commit messages:
 - 8299829: In jshell, the output of "0".repeat(49999)+"2" ends with a '0'

Changes: https://git.openjdk.org/jdk/pull/11927/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11927&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8299829
  Stats: 5 lines in 1 file changed: 4 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/11927.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11927/head:pull/11927

PR: https://git.openjdk.org/jdk/pull/11927


More information about the kulla-dev mailing list