8180510: jshell tool: crash on entering pseudo-commands: /<id> or /-<n>
Reviewed-by: jlahoda
--- 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) {