Jshell throws an error and crashes when using keyword Public

XMLWordPrintable

    • b17
    • 19
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Tested on MacOS 26.2 & Ubuntu 24.04.3 LTS

      A DESCRIPTION OF THE PROBLEM :
      While testing around with the jshell, i discovered that the jshell crashes and throws an error when using the Keyword "public" in specific cases. When leaving it out it wont crash and will just throw an error. If you try to reopen the jshell and then get to the last thing that was sended in the jshell, the jshell will just crash again

      REGRESSION : Last worked in version 24

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Open jshell
      public void E test(){E[] myarr = new Object[10];}

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      | Error:
      | '(' expected
      | public void E test(){E[] myarr = new Object[10];}
      | ^-------------^

      ACTUAL -
      Exception in thread "main" java.lang.StringIndexOutOfBoundsException: Range [18, 14) out of bounds for length 49
      at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
      at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
      at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
      at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
      at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
      at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
      at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
      at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4950)
      at java.base/java.lang.String.substring(String.java:2912)
      at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext$HighlighterImpl.highlight(ConsoleIOContext.java:1418)
      at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.getHighlightedBuffer(LineReaderImpl.java:4127)
      at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.getDisplayedBufferWithPrompts(LineReaderImpl.java:4065)
      at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.redisplay(LineReaderImpl.java:3933)
      at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.doCleanup(LineReaderImpl.java:2601)
      at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.cleanup(LineReaderImpl.java:2592)
      at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:777)
      at jdk.internal.le/jdk.internal.org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:512)
      at jdk.jshell/jdk.internal.jshell.tool.ConsoleIOContext.readLine(ConsoleIOContext.java:229)
      at jdk.jshell/jdk.internal.jshell.tool.JShellTool.getInput(JShellTool.java:1308)
      at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1242)
      at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:1027)
      at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:273)
      at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)

      ---------- BEGIN SOURCE ----------
      public void E test(){E[] myarr = new Object[10];}
      ---------- END SOURCE ----------

            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: