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

JShell: No custom input (e.g. from GUI) possible with JavaShellToolBuilder

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b24
    • Introduced In Version:
      11
    • Resolved In Build:
      b25
    • CPU:
      x86_64
    • OS:
      linux

      Backports

        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


          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved: