8139751: Javac crash with -XDallowStringFolding=false
authorjlahoda
Mon, 19 Oct 2015 12:41:45 +0200
changeset 33361 1c96344ecd49
parent 33360 d8ef08003d35
child 33362 65ec6de1d6b4
8139751: Javac crash with -XDallowStringFolding=false Summary: When string folding is disabled, need to keep the original expression. Reviewed-by: mcimadamore
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
langtools/test/tools/javac/parser/StringFoldingTest.java
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Sep 11 16:34:24 2015 -0700
+++ b/langtools/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/langtools/test/tools/javac/parser/StringFoldingTest.java	Fri Sep 11 16:34:24 2015 -0700
+++ b/langtools/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");
             }
         }
     }