8139751: Javac crash with -XDallowStringFolding=false
Summary: When string folding is disabled, need to keep the original expression.
Reviewed-by: mcimadamore
--- 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");
}
}
}