duke@1: /** duke@1: * @test /nodynamiccopyright/ duke@1: * @bug 4986256 jjg@611: * @compile/ref=FallThrough.noLint.out -XDrawDiagnostics FallThrough.java jjg@611: * @compile/ref=FallThrough.lintAll.out -Xlint:all,-path -XDrawDiagnostics FallThrough.java jjg@611: * @compile/ref=FallThrough.lintFallThrough.out -Xlint:fallthrough -XDrawDiagnostics FallThrough.java duke@1: */ duke@1: duke@1: // control: this class should generate a warning duke@1: class FallThrough duke@1: { duke@1: int m1(int i) { duke@1: switch (i) { duke@1: case 1: i++; case 2: i++; duke@1: } duke@1: return i; duke@1: } duke@1: } duke@1: duke@1: // tests: the warnings that would otherwise be generated should all be suppressed duke@1: @SuppressWarnings("fallthrough") duke@1: class FallThrough1 duke@1: { duke@1: int m1(int i) { duke@1: switch (i) { duke@1: case 1: i++; case 2: i++; duke@1: } duke@1: return i; duke@1: } duke@1: } duke@1: duke@1: class FallThrough2 duke@1: { duke@1: @SuppressWarnings("fallthrough") duke@1: class Bar { duke@1: int m1(int i) { duke@1: switch (i) { duke@1: case 1: i++; case 2: i++; duke@1: } duke@1: return i; duke@1: } duke@1: } duke@1: duke@1: @SuppressWarnings("fallthrough") duke@1: void m2(int i) { duke@1: switch (i) { duke@1: case 1: i++; case 2: i++; duke@1: } duke@1: } duke@1: duke@1: duke@1: @SuppressWarnings("fallthrough") duke@1: static int x = new FallThrough2() { duke@1: int m1(int i) { duke@1: switch (i) { duke@1: case 1: i++; case 2: i++; duke@1: } duke@1: return i; duke@1: } duke@1: }.m1(0); duke@1: duke@1: }