class X {
int switchTest(Object obj) {
return switch (obj) {
case (String s) -> 1;
case Integer i when predicate() -> 2;
case Integer i -> 3;
case default -> 4;
case null -> 10;
};
}
void testCaseDefault(int num) {
switch (num) {
case default -> {}
}
}
int instanceofTest(Object obj) {
if (obj instanceof (Integer i) && predicate()) {
return 1;
}
if (obj instanceof (String s)) {
return 3;
}
return 2;
}
native static boolean predicate();
}