JD.BITR

JD.BITR happens when an if check contains only constants on both sides. It can be the result of a programming error followed by compiler optimization which replaces expressions with constants. As a sub-case, this checker will trigger accidental assignments in conditions such as those in the example below. Note: Whether or not this error occurs depends on how the Java compiler optimizes the code. For some compilers, JD.BITR never occurs and either JD.RC.EXPR.DEAD or JD.RC.EXPR.CHECK occurs instead.

Vulnerability and risk

A statically evaluatable expression in an 'if' statement is most likely an error in logic.

Mitigation and prevention

Fix the 'if' statement.

Example 1

Copy
     static void check(boolean hasFields) {
         if (hasFields = true) {
             foo();
         }
         return;
     }

JD.BITR is reported for lline 11: Expression 'hasFields = true' is always 'true'. Is there a typo?