Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8306560 Add TOOLING.jsh load file
  3. JDK-8314499

Release Note: JDK Tool Access in JShell

    XMLWordPrintable

Details

    Description

      The JShell tool for interactive exploration of Java code has been enhanced with a new predefined script, `TOOLING`. The `TOOLING` script provides direct access to the JDK's command line tools, such as `javac`, `javadoc`, and `javap`, from within JShell.

      Similar to the existing predefined `DEFAULT` and `PRINTING` scripts, the `TOOLING` script can be loaded when JShell starts by running: `jshell TOOLING`. Alternatively, it can be loaded within a JShell session by using: `/open TOOLING`. With the `TOOLING` script loaded, JDK tools can be run by passing a name and arguments to the method `run(String name, String... args)`. The method `tools()` prints the names of available tools.

      The `TOOLING` script defines convenience methods for the most commonly used tools, such as `javac(String... args)`. Here is an example of running the `javap` tool that disassembles and prints an overview of a class or interface:

      ```text
      jshell> interface Empty {}
      jshell> javap(Empty.class)
      ```

      Attachments

        Activity

          People

            cstein Christian Stein
            cstein Christian Stein
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: