Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8157208

jshell tool: pluggable commands

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 9
    • Fix Version/s: tbd_major
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Allow commands to be added to the jshell tool.

      A plug-in mechanism is advantageous over the code copying/modification approach for several reasons including that the base code quickly goes out of date.

      Below is a first sketch of what the interface to the plug-in might be.

      Many questions yet:
      besides/instead of the command, how should the plug-in be installed?
      where should the API live?
      what should the actual API be?
      what information might a tool need?
      -------

      // Interface to implement
      interface CommandCreator {
          boolean register(CommandRegistrar registrar);
      }

      // Provided to the above
      interface CommandRegistrar {
          interface CompletionProvider {
              List<Suggestion> completionSuggestions(String input, int cursor, int[] anchor);
          }
          JShell state(); // JShell instance of the tool
          String command(String cmd); // command or snippet in, return all output as String
          void output(String format, Object... args);
          void error(String format, Object... args);
          void fluff(String format, Object... args);
          void rawOutput(String format, Object... args);
          boolean registerCommand(String name,
              String params,
              String help,
              Function<String,Boolean> run,
              CompletionProvider completions,
              boolean shouldReplay);
      }

      // jshell-tool command to install the plug-n

      /set command <class name (implementor of CommandCreator)>

        Attachments

          Activity

            People

            • Assignee:
              shinyafox Shinya Yoshida
              Reporter:
              rfield Robert Field
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: