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

No compilation error when switch expression has no result expressions

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 13
    • Fix Version/s: 13
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b28
    • Verification:
      Verified

      Backports

        Description

        The below code should throw a compilation error as there is no result expression for the switch expression. However, the compilation goes through successfully.

        public class SwitchTest {

            public static void main(String[] args) throws MyException {
                int i = 0;
                int a = switch (i) {
                    default -> throw new MyException();
                };
                System.out.println(a);
            }

        }

        class MyException extends Exception {

        }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jlahoda Jan Lahoda
                  Reporter:
                  vkhatri Vinod Khatri
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: