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

14.22: Completion of switch statement with switch rules but no default

XMLWordPrintable

      As reported [1], JLS14 14.22 [2] does not believe that the following switch statement can complete normally:

      switch (b) {
         case 1 -> throw new Exception();
      }

      However, when b is != 1, the switch statement does, in fact, complete normally, per 14.11.3. The definition of "can complete normally" for a switch statement whose switch block consists of switch rules is missing the clause:

      " - The switch block does not contain a default label."

      [1] http://mail.openjdk.java.net/pipermail/amber-spec-experts/2020-May/002211.html
      [2] https://docs.oracle.com/javase/specs/jls/se14/html/jls-14.html#jls-14.22

            abuckley Alex Buckley
            gbierman Gavin Bierman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: