Integrated: 8299829: In jshell, the output of "0".repeat(49999)+"2" ends with a '0'
Adam Sotona
asotona at openjdk.org
Wed Jan 11 08:34:22 UTC 2023
On Tue, 10 Jan 2023 15:42:31 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
This pull request has now been integrated.
Changeset: 030e88d6
Author: Adam Sotona <asotona at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/030e88d63844f185b839977ff1b19bbc4fe688e8
Stats: 8 lines in 2 files changed: 5 ins; 0 del; 3 mod
8299829: In jshell, the output of "0".repeat(49999)+"2" ends with a '0'
Reviewed-by: jlahoda
-------------
PR: https://git.openjdk.org/jdk/pull/11927
More information about the kulla-dev
mailing list