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

jshell throws EOF error when throwing exception inside switch expression

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b23
    • CPU:
      generic
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      18-ea+14-756

      A DESCRIPTION OF THE PROBLEM :
      JShell fails to parse certain switch expressions when entered interactively line by line, giving "Error: reached end of file while parsing"

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Enter the following, line per line, in JShell:
      void foo(String bar) {
      int v = switch(bar) {
      case "one" -> throw new RuntimeException();

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      JShell displays the prompt to enter the next line
      ACTUAL -
      | Error:
      | reached end of file while parsing
      | case "one" -> throw new RuntimeException();
      | ^

      CUSTOMER SUBMITTED WORKAROUND :
      Enter everything on a single line. For example, entering the following line works:
      void foo(String bar) { int v = switch(bar) { case "one" -> throw new RuntimeException(); default -> 2;};}

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: