1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8206986
4 * @summary Verify that not allowed types of statements cannot be used in rule case.
5 * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source 12 SwitchStatementBroken2.java
6 */
7
8 public class SwitchStatementBroken2 {
9
10 private void statementArrowNotArbitraryStatements(int i, int j) {
11 String res;
12
13 switch (i) {
14 case 0 -> res = "NULL-A";
15 case 1 -> { res = "NULL-A"; }
16 case 2 -> throw new IllegalStateException();
17 case 3 -> if (j < 0) res = "A"; else res = "B";
18 case 4 -> while (j-- > 0) res += "I";
19 case 5 -> switch (j) {
20 case 0: res = "0"; break;
21 }
22 case 7 -> int i;
23 default -> if (j < 0) res = "A"; else res = "B";
24 }
25 }
|
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8206986
4 * @summary Verify that not allowed types of statements cannot be used in rule case.
5 * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source 13 SwitchStatementBroken2.java
6 */
7
8 public class SwitchStatementBroken2 {
9
10 private void statementArrowNotArbitraryStatements(int i, int j) {
11 String res;
12
13 switch (i) {
14 case 0 -> res = "NULL-A";
15 case 1 -> { res = "NULL-A"; }
16 case 2 -> throw new IllegalStateException();
17 case 3 -> if (j < 0) res = "A"; else res = "B";
18 case 4 -> while (j-- > 0) res += "I";
19 case 5 -> switch (j) {
20 case 0: res = "0"; break;
21 }
22 case 7 -> int i;
23 default -> if (j < 0) res = "A"; else res = "B";
24 }
25 }
|