mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8205393: Add SourceVersion.RELEASE_13 8205394: Add source 13 and target 13 to javac 8205645: Bump maximum recognized class file version to 57 for JDK 13 8214825: Update preview language features for start of JDK 13 Reviewed-by: erikj, alanb, mchung, mcimadamore, dholmes, smarks, jjg
58 lines
1.5 KiB
Java
58 lines
1.5 KiB
Java
/*
|
|
* @test /nodynamiccopyright/
|
|
* @bug 8206986
|
|
* @summary Verify reachability in switch expressions.
|
|
* @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchUnreachable.java
|
|
*/
|
|
|
|
public class ExpressionSwitchUnreachable {
|
|
|
|
public static void main(String[] args) {
|
|
int z = 42;
|
|
int i = switch (z) {
|
|
case 0 -> {
|
|
break 42;
|
|
System.out.println("Unreachable"); //Unreachable
|
|
}
|
|
default -> 0;
|
|
};
|
|
i = switch (z) {
|
|
case 0 -> {
|
|
break 42;
|
|
break 42; //Unreachable
|
|
}
|
|
default -> 0;
|
|
};
|
|
i = switch (z) {
|
|
case 0:
|
|
System.out.println("0");
|
|
break 42;
|
|
System.out.println("1"); //Unreachable
|
|
default : break 42;
|
|
};
|
|
i = switch (z) {
|
|
case 0 -> 42;
|
|
default -> {
|
|
break 42;
|
|
System.out.println("Unreachable"); //Unreachable
|
|
}
|
|
};
|
|
i = switch (z) {
|
|
case 0: break 42;
|
|
default:
|
|
System.out.println("0");
|
|
break 42;
|
|
System.out.println("1"); //Unreachable
|
|
};
|
|
i = switch (z) {
|
|
case 0:
|
|
default:
|
|
System.out.println("0");
|
|
break 42;
|
|
System.out.println("1"); //Unreachable
|
|
};
|
|
}
|
|
|
|
|
|
}
|