Mon, 28 Feb 2011 13:42:24 -0800
7022711: compiler crash in try-with-resources
Reviewed-by: mcimadamore
1 /**
2 * @test /nodynamiccopyright/
3 * @bug 4986256
4 * @compile/ref=FallThrough.noLint.out -XDrawDiagnostics FallThrough.java
5 * @compile/ref=FallThrough.lintAll.out -Xlint:all,-path -XDrawDiagnostics FallThrough.java
6 * @compile/ref=FallThrough.lintFallThrough.out -Xlint:fallthrough -XDrawDiagnostics FallThrough.java
7 */
9 // control: this class should generate a warning
10 class FallThrough
11 {
12 int m1(int i) {
13 switch (i) {
14 case 1: i++; case 2: i++;
15 }
16 return i;
17 }
18 }
20 // tests: the warnings that would otherwise be generated should all be suppressed
21 @SuppressWarnings("fallthrough")
22 class FallThrough1
23 {
24 int m1(int i) {
25 switch (i) {
26 case 1: i++; case 2: i++;
27 }
28 return i;
29 }
30 }
32 class FallThrough2
33 {
34 @SuppressWarnings("fallthrough")
35 class Bar {
36 int m1(int i) {
37 switch (i) {
38 case 1: i++; case 2: i++;
39 }
40 return i;
41 }
42 }
44 @SuppressWarnings("fallthrough")
45 void m2(int i) {
46 switch (i) {
47 case 1: i++; case 2: i++;
48 }
49 }
52 @SuppressWarnings("fallthrough")
53 static int x = new FallThrough2() {
54 int m1(int i) {
55 switch (i) {
56 case 1: i++; case 2: i++;
57 }
58 return i;
59 }
60 }.m1(0);
62 }