test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 59021 cfc7bb9a5a92
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com

/*
 * @test /nodynamiccopyright/
 * @bug 8206986
 * @summary Verify that not allowed types of statements cannot be used in rule case.
 * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics 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";
        }
    }

}