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

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

XMLWordPrintable

    • b17
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      $ lsb_release -a
      No LSB modules are available.
      Distributor ID: Ubuntu
      Description: Ubuntu 22.04.1 LTS
      Release: 22.04
      Codename: jammy

      $ java --version
      openjdk 19.0.1 2022-10-18
      OpenJDK Runtime Environment (build 19.0.1+10-21)
      OpenJDK 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

      $ jshell --version
      jshell 19.0.1


      A DESCRIPTION OF THE PROBLEM :
      When running jshell, System.console() should not return null.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Launch jshell (without any redirection)
      2. In jshell, enter System.console()

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The expected result is for jshell to behave, apart from its REPL capabilities, as similar to java as possible. That includes the provision of a Console through System.console() to use jshell's REPL to tinker with java.io.Console.
      ACTUAL -
      The actual result is that in jshell, System.console() returns null, which makes using jshell's REPL to tinker with java.io.Console impossible.

      CUSTOMER SUBMITTED WORKAROUND :
      * One could write their own Java shell that doesn't have this defect.
      * One could use java to tinker with Console.log()
      Both workaround defeat the purpose of existence of jshell in this context.

            jlahoda Jan Lahoda
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: