changeset 45602:7aeef976cb06

8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n> Reviewed-by: jlahoda
author rfield
date Fri, 16 Jun 2017 10:32:46 -0700
parents f0530afb3b91
children 2161c0003389
files langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java langtools/test/jdk/jshell/ToolSimpleTest.java
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Jun 16 04:54:37 2017 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Jun 16 10:32:46 2017 -0700
@@ -1706,9 +1706,13 @@
         // Documentation pseudo-commands
         registerCommand(new Command("/<id>",
                 "help.id",
+                arg -> cmdHelp("rerun"),
+                EMPTY_COMPLETION_PROVIDER,
                 CommandKind.HELP_ONLY));
         registerCommand(new Command("/-<n>",
                 "help.previous",
+                arg -> cmdHelp("rerun"),
+                EMPTY_COMPLETION_PROVIDER,
                 CommandKind.HELP_ONLY));
         registerCommand(new Command("intro",
                 "help.intro",
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java	Fri Jun 16 04:54:37 2017 +0000
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java	Fri Jun 16 10:32:46 2017 -0700
@@ -388,6 +388,14 @@
         );
     }
 
+    @Test
+    public void testConfusedUserPseudoCommands() {
+        test(
+                (a) -> assertHelp(a, "/-<n>", "last snippet", "digits"),
+                (a) -> assertHelp(a, "/<id>", "last snippet", "digits")
+        );
+    }
+
     private void assertHelp(boolean a, String command, String... find) {
         assertCommandCheckOutput(a, command, s -> {
             for (String f : find) {