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

System.in.read() etc. don't accept input once immediate Ctrl+D pressed in JShell

XMLWordPrintable

    • b06
    • 26
    • master
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      openjdk 26-ea 2026-03-17
      OpenJDK Runtime Environment (build 26-ea+6-582)
      OpenJDK 64-Bit Server VM (build 26-ea+6-582, mixed mode, sharing)

      Windows 24H2

      A DESCRIPTION OF THE PROBLEM :

      This is a regression caused by the fact that the fix (https://github.com/openjdk/jdk/pull/25713 / https://github.com/openjdk/jdk/commit/9449fea2cd7aa7375f1b127e5f0d2a36ffaa1814) for JDK-8358552 is not sufficient. I personally tried to fix that bug by myself but gave up due to *this* regression.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. jdk-26/bin/jshell
      2. jshell> IO.readln() or jshell> System.in.read()
      3. Press Ctrl + D
      4. Run 2. once again

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      JShell pauses for additional input like when 2.
      ACTUAL -
      JShell won't accept input and returns the same result as 3.

      The fact that the empty lines between the commands and the results in $2 or later lack shows that JShell didn't pause there.

      ===== IO.readln() =====

      jshell> IO.readln()

      $1 ==> null

      jshell> IO.readln()
      $2 ==> null

      jshell> IO.readln()
      $3 ==> null

      ===== System.in.read() =====

      jshell> System.in.read()

      $1 ==> -1

      jshell> System.in.read()
      $2 ==> -1

      jshell> System.in.read()
      $3 ==> -1

      jshell> System.in.read()
      $4 ==> -1

      ---------- BEGIN SOURCE ----------
      // JShell only
      ---------- END SOURCE ----------

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

              Created:
              Updated:
              Resolved: