test/tools/javac/warnings/FallThrough.java

Tue, 03 Jun 2008 13:26:47 -0700

author
jjg
date
Tue, 03 Jun 2008 13:26:47 -0700
changeset 46
7708bd6d800d
parent 1
9a66ca7c79fa
child 611
4172cfff05f0
permissions
-rw-r--r--

4075303: Use javap to enquire aboput a specific inner class
4348375: Javap is not internationalized
4459541: "javap -l" shows line numbers as signed short; they should be unsigned
4501660: change diagnostic of -help as 'print this help message and exit'
4776241: unused source file in javap...
4870651: javap should recognize generics, varargs, enum
4876942: javap invoked without args does not print help screen
4880663: javap could output whitespace between class name and opening brace
4975569: javap doesn't print new flag bits
6271787: javap dumps LocalVariableTypeTable attribute in hex, needs to print a table
6305779: javap: support annotations
6439940: Clean up javap implementation
6469569: wrong check of searchpath in JavapEnvironment
6474890: javap does not open .zip files in -classpath
6587786: Javap throws error : "ERROR:Could not find <classname>" for JRE classes
6622215: javap ignores certain relevant access flags
6622216: javap names some attributes incorrectly
6622232: javap gets whitespace confused
6622260: javap prints negative bytes incorrectly in hex
Reviewed-by: ksrini

     1 /**
     2  * @test  /nodynamiccopyright/
     3  * @bug 4986256
     4  * @compile/ref=FallThrough.noLint.out -XDstdout                             -XDrawDiagnostics FallThrough.java
     5  * @compile/ref=FallThrough.lintAll.out -XDstdout         -Xlint:all,-path   -XDrawDiagnostics FallThrough.java
     6  * @compile/ref=FallThrough.lintFallThrough.out -XDstdout -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