View Javadoc
1   /*
2   DescendantToken
3   limitedTokens = LITERAL_RETURN
4   minimumDepth = (default)0
5   maximumDepth = (default)2147483647
6   minimumNumber = (default)0
7   maximumNumber = 0
8   sumTokenCounts = (default)false
9   minimumMessage = (default)null
10  maximumMessage = Return from catch is not allowed.
11  tokens = LITERAL_CATCH
12  
13  
14  */
15  
16  package com.puppycrawl.tools.checkstyle.checks.descendanttoken;
17  
18  public class InputDescendantTokenReturnFromCatch {
19      public void foo() {
20          try {
21              System.currentTimeMillis();
22          } catch (Exception e) { // violation 'Return from catch is not allowed'
23              return;
24          }
25      }
26  
27      public void bar() {
28          try {
29              System.currentTimeMillis();
30          } catch (Exception e) { // violation 'Return from catch is not allowed'
31              if (System.currentTimeMillis() == 0) {
32                  return; // return from if statement
33              }
34          }
35      }
36  }