Skip to content
Permalink
Browse files

8232681: ArrayIndexOutOfBoundsException with text blocks in javac whe…

…n using -Xlint

Reviewed-by: sundar
  • Loading branch information
JimLaskey committed Dec 5, 2019
1 parent c023983 commit 945c8d555b071e8d798712d60e0cef82957986ab
@@ -322,8 +322,8 @@ private static int indent(String line) {
String[] lines = string.split("\\R");
int length = lines.length;
// Extract last line.
String lastLine = lines[length - 1];
if (!optOut) {
String lastLine = length == 0 ? "" : lines[length - 1];
if (!optOut) {
// Prime with the last line indentation (may be blank.)
outdent = indent(lastLine);
for (String line : lines) {
@@ -24,6 +24,7 @@
/*
* @test
* @bug 8223967
* @bug 8232681
* @summary Unit tests for Text Block language changes
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
@@ -49,6 +50,7 @@ public static void main(String... args) {
test5();
test6();
test7();
test8();
}

/*
@@ -195,6 +197,23 @@ static void test7() {
"}");
}

static void test8() {
String code = "class C {\n" +
"\n" +
" void x() {\n" +
" String s = \"\"\"\n" +
"\n" +
"\"\"\";\n" +
" }\n" +
"}\n";

new JavacTask(TOOLBOX)
.sources(code)
.classpath(".")
.options("--enable-preview", "-source", JDK_VERSION, "-encoding", "utf8", "-Xlint")
.run();
}

/*
* Test source for successful compile.
*/

0 comments on commit 945c8d5

Please sign in to comment.
You can’t perform that action at this time.