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

jshell: System.in does not work inside a script file

    XMLWordPrintable

Details

    • x86_64
    • generic

    Description

      A DESCRIPTION OF THE PROBLEM :
      While System.in works from a snippet entered directly at the jshell prompt, it does not work from inside a script file loaded using /open or on the command line. Specifically, when calling System.in.read() from inside a script file, it returns -1 (end of file) without waiting for input from the user.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a script file test.jsh containing the statement

      System.out.println(System.in.read());

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      jshell blocks until a line of text is entered and then prints the ASCII code of the first character.
      ACTUAL -
      jshell does not block; it prints -1 (indicating end of file) and shows a prompt.

      ---------- BEGIN SOURCE ----------
      See above
      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        Activity

          People

            rfield Robert Field (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: