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

JShell crashes because it interprets a String as a "format"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 11
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      The expression:
      new URI("http", "localhost", "a bug", null)
      attempts to create a URI containing a space. The space is converted to "%20". However, since the third argument is invalid (it must start with a slash), an exception is thrown. Now the problem is, that JShell displays the exception using java.io.PrintStream::printf. Because "%20b" has a special meaning in a "format", an extra argument is expected. And since there isn't any available, an exception is thrown and JShell crashes.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      In jshell, enter:
      new URI("http", "localhost", "a bug", null)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      An exception is printed (because the third constructor argument must start with a slash)
      ACTUAL -
      JShell crashes with the following:

      | Exception java.net.URISyntaxException: Relative path in absolute URI: http://localhostaException in thread "main" java.util.MissingFormatArgumentException: Format specifier '%20d'
              at java.base/java.util.Formatter.format(Formatter.java:2672)
              at java.base/java.io.PrintStream.format(PrintStream.java:1053)
              at java.base/java.io.PrintStream.printf(PrintStream.java:949)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.error(JShellTool.java:728)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.errormsg(JShellTool.java:867)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.displayEvalException(JShellTool.java:3451)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.displayException(JShellTool.java:3425)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.displayException(JShellTool.java:3418)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.handleEvent(JShellTool.java:3582)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3550)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1301)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1203)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1176)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:975)
              at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
              at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pmangal Priyanka Mangal (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: