Menu

#1298 SF_SWITCH_NO_DEFAULT false positive

3.x
closed-wont-fix
5
2014-09-19
2014-08-27
No

FindBugs 3.0.0 reports a missing default statement for this code (compiled with javac 7u65):

 public class Test {

   public void testFallthrough(int x) {
     switch (x) {
     case 1:
       System.out.println("irrelevant");
       //$FALL-THROUGH$
     default:
       System.out.println("irrelevant");
       break;
     }
   }
 }

Discussion

  • William Pugh

    William Pugh - 2014-09-19
    • status: open --> closed-wont-fix
    • assigned_to: William Pugh
     
  • William Pugh

    William Pugh - 2014-09-19

    We can't correctly exclude this case, because there aren't any break statements in the switch statement. I will change the documentation for the warning to note this case.

     

Log in to post a comment.

MongoDB Logo MongoDB