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

Jan Lahoda jlahoda at openjdk.org
Tue Jan 10 17:49:52 UTC 2023


On Tue, 10 Jan 2023 16:14:44 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> "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
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
> 
>   added test

Looks good to me. Thanks!

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

Marked as reviewed by jlahoda (Reviewer).

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


More information about the kulla-dev mailing list