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

Switch expressions may have constant type and may be skipped during write

    XMLWordPrintable

Details

    • b22
    • Verified

    Description

      Reported here:
      http://mail.openjdk.java.net/pipermail/compiler-dev/2018-November/012637.html

      Source code:
      ---
      public class Java12Test {
        public static void main(String[] args) {
          String s = "foo";
          System.out.println(s + switch(0) {
            default -> {
              s = "bar";
              break 1;
            }
          });
          System.out.println(s);
        }
      }
      ---

      Prints:
      ---
      foo1
      foo
      ---

      Attachments

        Activity

          People

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: