Mon, 19 Oct 2015 12:41:45 +0200
8139751: Javac crash with -XDallowStringFolding=false
Summary: When string folding is disabled, need to keep the original expression.
Reviewed-by: mcimadamore
1.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Jan 15 19:57:58 2016 +0300 1.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Oct 19 12:41:45 2015 +0200 1.3 @@ -980,7 +980,7 @@ 1.4 */ 1.5 protected JCExpression foldStrings(JCExpression tree) { 1.6 if (!allowStringFolding) 1.7 - return null; 1.8 + return tree; 1.9 ListBuffer<JCExpression> opStack = new ListBuffer<>(); 1.10 ListBuffer<JCLiteral> litBuf = new ListBuffer<>(); 1.11 boolean needsFolding = false;
2.1 --- a/test/tools/javac/parser/StringFoldingTest.java Fri Jan 15 19:57:58 2016 +0300 2.2 +++ b/test/tools/javac/parser/StringFoldingTest.java Mon Oct 19 12:41:45 2015 +0200 2.3 @@ -23,7 +23,7 @@ 2.4 2.5 /* 2.6 * @test 2.7 - * @bug 7068902 2.8 + * @bug 7068902 8139751 2.9 * @summary verify that string folding can be enabled or disabled 2.10 */ 2.11 2.12 @@ -85,11 +85,14 @@ 2.13 2.14 if (disableStringFolding) { 2.15 if (text.contains("FOLDED")) { 2.16 - throw new AssertionError("Expected string folding"); 2.17 + throw new AssertionError("Expected no string folding"); 2.18 + } 2.19 + if (!text.contains("\"F\"")) { 2.20 + throw new AssertionError("Expected content not found"); 2.21 } 2.22 } else { 2.23 if (!text.contains("FOLDED")) { 2.24 - throw new AssertionError("Expected no string folding"); 2.25 + throw new AssertionError("Expected string folding"); 2.26 } 2.27 } 2.28 }