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

StringIndexOutOfBoundsException upon auto-completion in Jshell

    XMLWordPrintable

Details

    • b164
    • 9
    • generic
    • generic

    Description

      FULL PRODUCT VERSION :
      java version "9"
      Java(TM) SE Runtime Environment (build 9+181)
      Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.10240]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Running Jshell in Cmder

      A DESCRIPTION OF THE PROBLEM :
      Auto-completion after a /drop command resulted in StringIndexOutOfBoundsException. Here is the full output of the commands:

      jshell> /vars
      | Set<String> myMutableSet = [four, one, two, three, five]
      | Set<String> unmodifiableSet = [four, one, two, three, five]
      | boolean $8 = true

      jshell> /drop myMutableSet unmoException in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
              at java.base/java.lang.String.substring(String.java:1852)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext$OrdinaryCompletionTask.perform(ConsoleIOContext.java:475)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.complete(ConsoleIOContext.java:287)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.access$000(ConsoleIOContext.java:69)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext$1.complete(ConsoleIOContext.java:100)
              at jdk.internal.le/jdk.internal.jline.console.ConsoleReader.readLine(ConsoleReader.java:2684)
              at jdk.internal.le/jdk.internal.jline.console.ConsoleReader.readLine(ConsoleReader.java:2279)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.readLine(ConsoleIOContext.java:139)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1140)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:929)
              at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.run(JShellToolBuilder.java:239)
              at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:119)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start Jshell and type in the following commands:
      1. String foo = "foo", bar = "bar"
      2. /drop foo b<Tab>

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The "bar" variable name is auto-completed.
      ACTUAL -
      java.lang.StringIndexOutOfBoundsException is thrown

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      jshell> String foo = "foo", bar = "bar"
      foo ==> "foo"
      bar ==> "bar"

      jshell> /drop foo
      delete a source entry referenced by name or id

      <press tab again to see full documentation>

      jshell> /drop foo bException in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
              at java.base/java.lang.String.substring(String.java:1852)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext$OrdinaryCompletionTask.perform(ConsoleIOContext.java:475)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.complete(ConsoleIOContext.java:287)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.access$000(ConsoleIOContext.java:69)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext$1.complete(ConsoleIOContext.java:100)
              at jdk.internal.le/jdk.internal.jline.console.ConsoleReader.readLine(ConsoleReader.java:2684)
              at jdk.internal.le/jdk.internal.jline.console.ConsoleReader.readLine(ConsoleReader.java:2279)
              at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.readLine(ConsoleIOContext.java:139)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1140)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:929)
              at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.run(JShellToolBuilder.java:239)
              at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:119)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      The workaround is to not use auto-completion when dropping multiple vars in Jshell.

      Attachments

        Issue Links

          Activity

            People

              fmatte Fairoz Matte
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: