test/langtools/tools/javac/StringsInSwitch/RepeatedStringCaseLabels2.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 50949 999f09bf3464
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
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 repeated string case labels.
6150
d055fa8ced62 6971882: Remove -XDstdout from javac test
jjg
parents: 4142
diff changeset
     5
 * @compile/fail/ref=RSCL2.out -XDrawDiagnostics RepeatedStringCaseLabels2.java
4142
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     6
 */
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     7
class RepeatedStringCaseLabels2 {
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     8
    String m(String s) {
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
     9
        final String constant = "Hello" + " " + "World";
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    10
        switch(s) {
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    11
        case "Hello World":
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    12
            return(s);
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    13
        case constant:
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    14
            return (s + s);
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    15
        }
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    16
    }
bd950c8f4fb3 6827009: Project Coin: Strings in Switch
darcy
parents:
diff changeset
    17
}