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

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

XMLWordPrintable

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

      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>

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

              Created:
              Updated:
              Resolved: