8261450: JShell crashes with SIOOBE in tab completion

Reviewed-by: vromero
This commit is contained in:
Jan Lahoda 2021-03-04 12:36:34 +00:00
parent b817855340
commit 94f26e4df8
2 changed files with 16 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -593,6 +593,7 @@ public class JavadocFormatter {
private void reflowTillNow() {
while (result.length() > 0 && result.charAt(result.length() - 1) == ' ')
result.delete(result.length() - 1, result.length());
reflownTo = Math.min(reflownTo, result.length());
reflow(result, reflownTo, indent, limit);
reflownTo = result.length();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/*
* @test
* @bug 8131019 8169561
* @bug 8131019 8169561 8261450
* @summary Test JavadocFormatter
* @library /tools/lib
* @modules jdk.compiler/jdk.internal.shellsupport.doc
@ -401,4 +401,16 @@ public class JavadocFormatterTest {
}
}
public void testSpaceAtEndOfLine() {
String header = "Class<?> Class<T>.forName(Module module, String name)";
String javadoc = """
@throws SecurityException
<ul>
<li> test </li>
</ul>
""";
new JavadocFormatter(60, true).formatJavadoc(header, javadoc);
}
}