changeset 3061:777c5a760a84

8139751: Javac crash with -XDallowStringFolding=false Summary: When string folding is disabled, need to keep the original expression. Reviewed-by: mcimadamore
author jlahoda
date Mon, 19 Oct 2015 12:41:45 +0200
parents 23f76aadbb36
children 15bdc18525ff
files src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java test/tools/javac/parser/StringFoldingTest.java
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Sep 11 16:34:24 2015 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Oct 19 12:41:45 2015 +0200
@@ -973,7 +973,7 @@
          */
         protected JCExpression foldStrings(JCExpression tree) {
             if (!allowStringFolding)
-                return null;
+                return tree;
             ListBuffer<JCExpression> opStack = new ListBuffer<>();
             ListBuffer<JCLiteral> litBuf = new ListBuffer<>();
             boolean needsFolding = false;
--- a/test/tools/javac/parser/StringFoldingTest.java	Fri Sep 11 16:34:24 2015 -0700
+++ 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
  * @modules jdk.compiler
  */
@@ -86,11 +86,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");
             }
         }
     }