Switch expression causes infinite loop

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • 23
    • Affects Version/s: 22, 23
    • Component/s: tools
    • None

      Running the following code snippet on current JDK causes an infinite loop:

      class Scratch {
        public static int matcher(Object l, Object r) {
          record Pair(Object left, Object right) { }
          return switch (new Pair(l, r)) {
            case Pair(Byte b, var $$) -> 1;
            case Pair(var $, Byte str) -> 1;
            default -> -1;
          };
        }

        public static void main(String[] args) {
          System.out.println(matcher(null, "1"));
        }
      }

      This was originally reported here: https://github.com/SAP/SapMachine/issues/1571

            Assignee:
            Jan Lahoda
            Reporter:
            Christoph Langer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: