From ae7f261a4ad00af87183f066e154ae6b371fdac0 Mon Sep 17 00:00:00 2001 From: jlahoda Date: Mon, 19 Oct 2015 12:41:45 +0200 Subject: [PATCH] 8139751: Javac crash with -XDallowStringFolding=false Summary: When string folding is disabled, need to keep the original expression. Reviewed-by: mcimadamore --- .../classes/com/sun/tools/javac/parser/JavacParser.java | 2 +- test/tools/javac/parser/StringFoldingTest.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) 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 b8d9c026..9cdb4628 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 32a59d72..9ad6f719 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"); } } } -- GitLab