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
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
- duplicates
-
JDK-8326129 Java Record Pattern Match leads to infinite loop
-
- Resolved
-