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

jshell tool: crash when code with syntax error contains format specifier

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b111
    • Resolved In Build:
      b120
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      FULL PRODUCT VERSION :
      jshell> Bobs-MacBook-Pro:bin bob$ ./java -version
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+116)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+116, mixed mode)
      Bobs-MacBook-Pro:b

      FULL OS VERSION :
      Bobs-MacBook-Pro:bin bob$ uname -a
      Darwin Bobs-MacBook-Pro.local 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64
      Bobs-MacBook-Pro:bin bo

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      OSX El Capitan, all current patches.

      A DESCRIPTION OF THE PROBLEM :
      The (syntax error) command: System.out.println("%5d", 10); causes jshell to exit.
      The command: System.out.println("hello"); leaves jsheell running.


      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start jshell.
      Enter the command: System.out.println("%5d", 10);


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected: Should give an error message but continue.
      Actual: gives error message, then stacktrace and jshell quits.
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Bobs-MacBook-Pro:~ bob$ cd /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin
      Bobs-MacBook-Pro:bin bob$ ./jshell
      | Welcome to JShell -- Version 9-ea
      | For an introduction type: /help intro


      jshell> System.out.println("%5d", 10);
      | Error:
      | no suitable method found for println(java.lang.String,int)
      | method java.io.PrintStream.println() is not applicable
      | (actual and formal argument lists differ in length)
      | method java.io.PrintStream.println(boolean) is not applicable
      | (actual and formal argument lists differ in length)
      | method java.io.PrintStream.println(char) is not applicable
      | (actual and formal argument lists differ in length)
      | method java.io.PrintStream.println(int) is not applicable
      | (actual and formal argument lists differ in length)
      | method java.io.PrintStream.println(long) is not applicable
      | (actual and formal argument lists differ in length)
      | method java.io.PrintStream.println(float) is not applicable
      | (actual and formal argument lists differ in length)
      | method java.io.PrintStream.println(double) is not applicable
      | (actual and formal argument lists differ in length)
      | method java.io.PrintStream.println(char[]) is not applicable
      | (actual and formal argument lists differ in length)
      | method java.io.PrintStream.println(java.lang.String) is not applicable
      | (actual and formal argument lists differ in length)
      | method java.io.PrintStream.println(java.lang.Object) is not applicable
      | (actual and formal argument lists differ in length)
      | System.out.println("Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '%5d'
      at java.util.Formatter.format(java.base@9-ea/Formatter.java:2524)
      at java.io.PrintStream.format(java.base@9-ea/PrintStream.java:974)
      at java.io.PrintStream.printf(java.base@9-ea/PrintStream.java:873)
      at jdk.internal.jshell.tool.JShellTool.rawout(jdk.jshell@9-ea/JShellTool.java:230)
      at jdk.internal.jshell.tool.JShellTool.hard(jdk.jshell@9-ea/JShellTool.java:240)
      at jdk.internal.jshell.tool.JShellTool.lambda$handleEvent$70(jdk.jshell@9-ea/JShellTool.java:1832)
      at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(java.base@9-ea/ArrayList.java:1477)
      at java.util.stream.ReferencePipeline$Head.forEach(java.base@9-ea/ReferencePipeline.java:591)
      at jdk.internal.jshell.tool.JShellTool.handleEvent(jdk.jshell@9-ea/JShellTool.java:1832)
      at jdk.internal.jshell.tool.JShellTool.processCompleteSource(jdk.jshell@9-ea/JShellTool.java:1799)
      at jdk.internal.jshell.tool.JShellTool.processSource(jdk.jshell@9-ea/JShellTool.java:1784)
      at jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(jdk.jshell@9-ea/JShellTool.java:686)
      at jdk.internal.jshell.tool.JShellTool.run(jdk.jshell@9-ea/JShellTool.java:666)
      at jdk.internal.jshell.tool.JShellTool.start(jdk.jshell@9-ea/JShellTool.java:473)
      at jdk.internal.jshell.tool.JShellTool.start(jdk.jshell@9-ea/JShellTool.java:447)
      at jdk.internal.jshell.tool.JShellTool.main(jdk.jshell@9-ea/JShellTool.java:437)
      Bobs-MacBook-Pro:bin bob$ ./jshell
      | Welcome to JShell -- Version 9-ea
      | For an introduction type: /help intro


      jshell> System.out.println("hello");
      hello

      jshell>


      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Activity

            People

            Assignee:
            rfield Robert Field
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: