test/tools/javac/warnings/FallThrough.java

Tue, 24 Dec 2013 09:17:37 -0800

author
ksrini
date
Tue, 24 Dec 2013 09:17:37 -0800
changeset 2227
998b10c43157
parent 611
4172cfff05f0
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8029230: Update copyright year to match last edit in jdk8 langtools repository for 2013
Reviewed-by: ksrini
Contributed-by: steve.sides@oracle.com

     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 }

mercurial