TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - Java Coding Standard
Search

Rule:  StrictException102Checked automatically with code checker

Synopsis:Exception classes should only contain final fields
Language:Java
Severity Level:3
Category:StrictException


Description:
Exception classes should be immutable, that is, they should only have final fields. This is because Exception instances should represent an error condition. Having non final fields not only allows the state to be modified by accident and therefore mask the original condition but also allows developers to accidentally forget to set the initial state. In both cases, code catching the exception could draw incorrect conclusions based on the state.
public class MyException {
    int nonFinalMember; // violation
}