1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/StringsInSwitch/NonConstantLabel.java Mon Nov 02 21:36:59 2009 -0800 1.3 @@ -0,0 +1,18 @@ 1.4 +/* 1.5 + * @test /nodynamiccopyright/ 1.6 + * @bug 6827009 1.7 + * @summary Check for non-constant case labels. 1.8 + * @compile/fail -source 6 NonConstantLabel.java 1.9 + * @compile/fail/ref=NonConstantLabel.out -XDstdout -XDrawDiagnostics NonConstantLabel.java 1.10 + */ 1.11 +class NonConstantLabel { 1.12 + String m(String s) { 1.13 + String fauxConstant = "Goodbye Cruel World"; 1.14 + switch(s) { 1.15 + case "Hello World": 1.16 + return(s); 1.17 + case fauxConstant: 1.18 + return (s + s); 1.19 + } 1.20 + } 1.21 +}