Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -57,6 +57,10 @@ class ExecutionControlForwarder {
*/
private static final int MAX_UTF_CHARS = 21844;

private static final int TRUNCATE_END = MAX_UTF_CHARS / 3;
private static final String TRUNCATE_JOIN = " ... ";
private static final int TRUNCATE_START = MAX_UTF_CHARS - TRUNCATE_JOIN.length() - TRUNCATE_END;

private final ExecutionControl ec;
private final ObjectInput in;
private final ObjectOutput out;
Expand Down Expand Up @@ -108,7 +112,7 @@ private void writeUTF(String s) throws IOException {
s = "";
} else if (s.length() > MAX_UTF_CHARS) {
// Truncate extremely long strings to prevent writeUTF from crashing the VM
s = s.substring(0, MAX_UTF_CHARS);
s = s.substring(0, TRUNCATE_START) + TRUNCATE_JOIN + s.substring(s.length() - TRUNCATE_END);
}
out.writeUTF(s);
}
Expand Down
5 changes: 3 additions & 2 deletions test/langtools/jdk/jshell/ToolFormatTest.java
Expand Up @@ -23,7 +23,7 @@

/*
* @test
* @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261 8163840 8166637 8161969 8173007
* @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261 8163840 8166637 8161969 8173007 8299829
* @summary Tests for output customization
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
Expand Down Expand Up @@ -300,7 +300,8 @@ public void testSetTruncation() {
(a) -> assertCommand(a, "/var", "| String s = \"ABACABADA"),
(a) -> assertCommand(a, "String r = s", "String:\"ABACABAD ... BAXYZ\""),
(a) -> assertCommand(a, "r", "String:\"ABACABADA"),
(a) -> assertCommand(a, "r=s", "String:\"AB")
(a) -> assertCommand(a, "r=s", "String:\"AB"),
(a) -> assertCommand(a, "\"0\".repeat(49999)+\"2\"", "String:\"00000000 ... 00002\"")
);
} finally {
assertCommandCheckOutput(false, "/set feedback normal", s -> {
Expand Down