# HG changeset patch # User jlahoda # Date 1445251305 -7200 # Node ID ca136b17b9f415e4f078772e56d4844fdfb2aa91 # Parent 0ee1f3cdb4bac679f732612474c5a0717bbbe74a 8139751: Javac crash with -XDallowStringFolding=false Summary: When string folding is disabled, need to keep the original expression. Reviewed-by: mcimadamore diff -r 0ee1f3cdb4ba -r ca136b17b9f4 src/share/classes/com/sun/tools/javac/parser/JavacParser.java --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Jan 15 19:57:58 2016 +0300 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Oct 19 12:41:45 2015 +0200 @@ -980,7 +980,7 @@ */ protected JCExpression foldStrings(JCExpression tree) { if (!allowStringFolding) - return null; + return tree; ListBuffer opStack = new ListBuffer<>(); ListBuffer litBuf = new ListBuffer<>(); boolean needsFolding = false; diff -r 0ee1f3cdb4ba -r ca136b17b9f4 test/tools/javac/parser/StringFoldingTest.java --- a/test/tools/javac/parser/StringFoldingTest.java Fri Jan 15 19:57:58 2016 +0300 +++ b/test/tools/javac/parser/StringFoldingTest.java Mon Oct 19 12:41:45 2015 +0200 @@ -23,7 +23,7 @@ /* * @test - * @bug 7068902 + * @bug 7068902 8139751 * @summary verify that string folding can be enabled or disabled */ @@ -85,11 +85,14 @@ if (disableStringFolding) { if (text.contains("FOLDED")) { - throw new AssertionError("Expected string folding"); + throw new AssertionError("Expected no string folding"); + } + if (!text.contains("\"F\"")) { + throw new AssertionError("Expected content not found"); } } else { if (!text.contains("FOLDED")) { - throw new AssertionError("Expected no string folding"); + throw new AssertionError("Expected string folding"); } } }