View Javadoc
1   /*
2   MutableException
3   format = (default)^.*Exception$|^.*Error$|^.*Throwable$
4   extendedClassNameFormat = (default)^.*Exception$|^.*Error$|^.*Throwable$
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.design.mutableexception;
10  
11  public class InputMutableException {
12      public class FooException extends Exception {
13          private final int finalErrorCode;
14          private int errorCode = 1; // violation
15  
16          public FooException() {
17              finalErrorCode = 1;
18          }
19  
20          public class FooExceptionThisIsNot extends RuntimeException {
21              private final int finalErrorCode;
22              private int errorCode = 1;
23              /** constructor */
24              public FooExceptionThisIsNot() {
25                  finalErrorCode = 1;
26              }
27          }
28      }
29  
30      public class BarError extends Throwable {
31          private int errorCode; // violation
32      }
33  
34      public class BazDoesNotExtendError {
35          private int errorCode;
36      }
37  
38      public class CustomProblem extends ThreadDeath {
39          private int errorCode;
40  
41          public class CustomFailure extends ThreadDeath {
42              private int errorCode;
43              public void someMethod() {
44                  if(true) {
45                      final int i = 0;
46                  }
47              }
48          }
49      }
50  
51      class CustomException extends java.lang.Exception {}
52  
53      class CustomMutableException extends java.lang.Exception {
54          int errorCode; // violation
55      }
56  
57      class ExampleException extends java.lang.Exception {
58          public void test() {
59              Throwable cause = super.getCause();
60              if (!(cause instanceof java.io.IOException))
61                  throw new IllegalStateException("Test");
62          }
63      }
64  }