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

jshell - switch statement with a single default not return cause syntax error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 17
    • 12, 13, 14, 15
    • tools
    • b21

    Description

      In jshell, if I have a switch statement with a single default label that contains code not reaching the end of the switch statement, jshell will give a syntax error. That used to work in JDK 11.

      jshell> var foo = "foo"
      foo ==> "foo"

      jshell> switch (foo) { default: throw new AssertionError(); }
      | Error:
      | unreachable statement
      | switch (foo) { default: throw new AssertionError(); }
      | ^

      jshell>

      Attachments

        Issue Links

          Activity

            People

              jlahoda Jan Lahoda
              mtrudeau Michel Trudeau
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: