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