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

System.console() shouldn't return null in jshell

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • tools
    • None
    • source
    • minimal
    • Java API
    • JDK

      Summary

      An enhancement to the JShell API to support use of System.console() inside the snippets is proposed.

      Problem

      Currently, when a JShell snippet uses System.console(), the returned value is null.

      Solution

      The JShell API is enhanced to allow to specify a console backend for the snippet execution. Then, when a snippet runs, System.console() may return a non-null value, and invoking methods on this value will rely the data to the specified console backend and back.

      Not all JShell backends and configurations will support System.console(). Specifically, JShell will only support System.console() when it will use a remote agent, and the remote agent will support the console. This is the default when running JShell on the command line.

      Specification

      The proposed API changes are attached as specdiff.02.zip and are also available for convenience here: https://cr.openjdk.org/~jlahoda/8296454/specdiff.02/overview-summary.html

        1. specdiff.00.zip
          3.44 MB
        2. specdiff.01.zip
          3.45 MB
        3. specdiff.02.zip
          3.44 MB

            jlahoda Jan Lahoda
            webbuggrp Webbug Group
            Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: