test/langtools/tools/javac/StringsInSwitch/NonConstantLabel.java
author prr
Fri, 25 May 2018 12:12:24 -0700
changeset 50347 b2f046ae8eb6
parent 47216 71c04702a3d5
child 50949 999f09bf3464
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4142
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     1
/*
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     2
 * @test  /nodynamiccopyright/
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     3
 * @bug 6827009
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     4
 * @summary Check for non-constant case labels.
30715
099641abfb05 8074387: Group 11: golden files for coin tests in tools/javac dir
sogoel
parents: 6150
diff changeset
     5
 * @compile/fail/ref=NonConstantLabel6.out -XDrawDiagnostics -source 6 NonConstantLabel.java
6150
d055fa8ced62 6971882: Remove -XDstdout from javac test
jjg
parents: 4142
diff changeset
     6
 * @compile/fail/ref=NonConstantLabel.out -XDrawDiagnostics NonConstantLabel.java
4142
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     7
 */
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     8
class NonConstantLabel {
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     9
    String m(String s) {
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    10
        String fauxConstant = "Goodbye Cruel World";
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    11
        switch(s) {
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    12
        case "Hello World":
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    13
            return(s);
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    14
        case fauxConstant:
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    15
            return (s + s);
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    16
        }
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    17
    }
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    18
}