jdk-24/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java
Joe Darcy bf2d27c5a4 8219254: Update explicit uses of latest source/target in langtools tests to a property
8219256: Update javac diags tests to use properties

Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Reviewed-by: jjg, jlahoda, darcy, iignatyev
2019-02-21 10:29:16 -08:00

28 lines
873 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8206986
* @summary Verify that not allowed types of statements cannot be used in rule case.
* @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchStatementBroken2.java
*/
public class SwitchStatementBroken2 {
private void statementArrowNotArbitraryStatements(int i, int j) {
String res;
switch (i) {
case 0 -> res = "NULL-A";
case 1 -> { res = "NULL-A"; }
case 2 -> throw new IllegalStateException();
case 3 -> if (j < 0) res = "A"; else res = "B";
case 4 -> while (j-- > 0) res += "I";
case 5 -> switch (j) {
case 0: res = "0"; break;
}
case 7 -> int i;
default -> if (j < 0) res = "A"; else res = "B";
}
}
}