diff --git a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index b8d9c026d8639b99d5d6983130443d4f256c9b26..9cdb4628d658eb70d781cc04ee8254ea93911cb6 100644 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -980,7 +980,7 @@ public class JavacParser implements Parser { */ protected JCExpression foldStrings(JCExpression tree) { if (!allowStringFolding) - return null; + return tree; ListBuffer opStack = new ListBuffer<>(); ListBuffer litBuf = new ListBuffer<>(); boolean needsFolding = false; diff --git a/test/tools/javac/parser/StringFoldingTest.java b/test/tools/javac/parser/StringFoldingTest.java index 32a59d72d13f3ee12748d5897ad554bae964daad..9ad6f719e25b4a9e8f947ea960f0d5a098b164a0 100644 --- a/test/tools/javac/parser/StringFoldingTest.java +++ b/test/tools/javac/parser/StringFoldingTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 7068902 + * @bug 7068902 8139751 * @summary verify that string folding can be enabled or disabled */ @@ -85,11 +85,14 @@ public class StringFoldingTest { 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"); } } }