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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 12
    • Fix Version/s: 12
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b22
    • Verification:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: