JDK-8247403 : JShell: No custom input (e.g. from GUI) possible with JavaShellToolBuilder
  • Type: Bug
  • Component: tools
  • Sub-Component: jshell
  • Affected Version: 11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2020-06-07
  • Updated: 2021-09-10
  • Resolved: 2021-05-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 17
11.0.13-oracleFixed 17 b25Fixed
Related Reports
CSR :  
Duplicate :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
$ uname -a
Linux seneca 5.4.0-31-generic #35-Ubuntu SMP Thu May 7 20:20:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ java -version
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)


A DESCRIPTION OF THE PROBLEM :
An input stream provided to JavaShellToolBuilder isn't used in Java 14, confirmed working with Java 11

REGRESSION : Last worked in version 11.0.7

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Launch the provided source code, e.g. like this: "java JShellBug.java"


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
On system out the usage of the provided input stream should be reported on System.out
ACTUAL -
With java 14 the "read" method of the provided input stream is never called.

---------- BEGIN SOURCE ----------
// https://bugs.openjdk.java.net/browse/JDK-8246353?jql=%20Subcomponent%20%3D%20jshell%20and%20resolution%20is%20EMPTY%20ORDER%20BY%20created%20DESC
import jdk.jshell.tool.JavaShellToolBuilder;
import java.io.*;

/*
** The provided input stream is not used with java 14.0.1
**/
public class JShellBug {

    public static void main(String[] args) throws Exception {
       final InputStream input = new InputStream() {
                
           public int read() throws IOException {
               System.out.println("READ CALLED");
               Thread.dumpStack();
               return System.in.read();
           }
                
       };
       if (args.length == 0) {
          JavaShellToolBuilder.builder().in(input, null).run();
       } else {
          JavaShellToolBuilder.builder().in(input, input).run();
       }
    }
    
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Fix Request (11u): Fix is backported to 11.0.13-oracle, but it's still missing in OpenJDK 11.0.14. Doesn't apply cleanly. Review: https://github.com/openjdk/jdk11u-dev/pull/319
09-09-2021

Changeset: 2c8e94f6 Author: Jan Lahoda <jlahoda@openjdk.org> Date: 2021-05-31 09:25:16 +0000 URL: https://git.openjdk.java.net/jdk/commit/2c8e94f6804fee269a882a3e92b7ce844451eb11
31-05-2021

Related I/O changes
11-06-2020

OS: linux JDK 11.0.7 Pass JDK 12 ea 23 Pass JDK 12 ea 24 Fail JDK 14.0.1 Fail the "read" method of the provided input stream is called till jdk 12 ea 23 along with an exception "READ CALLED java.lang.Exception: Stack trace at java.base/java.lang.Thread.dumpStack(Thread.java:1383) at jshellBug$1.read(JShellBug.java:14) at jdk.jshell/jdk.internal.jshell.tool.StopDetectingInputStream.lambda$setInputStream$0(StopDetectingInputStream.java:66)" From 12 ea 24 JShell is working but Read method is not called.
11-06-2020