Merge
authorlana
Fri, 20 Jan 2017 19:12:30 +0000
changeset 43276 0f8dd574fa0a
parent 43274 6b5ed4f9fb81 (diff)
parent 43275 b73702608fc6 (current diff)
child 43278 e9f4ee9bfd86
Merge
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Jan 20 19:10:00 2017 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Jan 20 19:12:30 2017 +0000
@@ -987,7 +987,7 @@
                     break;
                 }
                 String trimmed = trimEnd(raw);
-                if (!trimmed.isEmpty()) {
+                if (!trimmed.isEmpty() || !incomplete.isEmpty()) {
                     String line = incomplete + trimmed;
 
                     // No commands in the middle of unprocessed source
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java	Fri Jan 20 19:10:00 2017 +0000
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java	Fri Jan 20 19:12:30 2017 +0000
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405
+ * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405 8173073
  * @summary Simple jshell tool tests
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -496,6 +496,35 @@
     }
 
     @Test
+    public void testBlankLinesInSnippetContinuation() {
+        test(Locale.ROOT, false, new String[]{"--no-startup"}, "",
+                a -> assertCommand(a, "class C {",
+                        ""),
+                a -> assertCommand(a, "",
+                        ""),
+                a -> assertCommand(a, "",
+                        ""),
+                a -> assertCommand(a, "  int x;",
+                        ""),
+                a -> assertCommand(a, "",
+                        ""),
+                a -> assertCommand(a, "",
+                        ""),
+                a -> assertCommand(a, "}",
+                        "|  created class C"),
+                a -> assertCommand(a, "/list",
+                        "\n" +
+                        "   1 : class C {\n" +
+                        "       \n" +
+                        "       \n" +
+                        "         int x;\n" +
+                        "       \n" +
+                        "       \n" +
+                        "       }")
+        );
+    }
+
+    @Test
     public void testCompoundStart() {
         test(new String[]{"--startup", "DEFAULT", "--startup", "PRINTING"},
                 (a) -> assertCommand(a, "printf(\"%4.2f\", Math.PI)",