--- 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)",