JD.BITCMP happens when an if check contains binary such as & or | instead of short-circuit, such as && or ||. It is better to use short-circuit operation for performance. Also, if you use binary, both sides of the expression are evaluated, and this can cause other unexpected problems, such as a null pointer exception being thrown. as in the example below.

Vulnerability and risk

A JD.BITCMP defect can cause a performance impact or unexpected behavior, such as a RuntimeException being thrown.

Mitigation and prevention

Replace bit operation with short-circuit operation.

Example 1

     static void check(int arr[]) {
         if (arr!=null & arr.length!=0) {

JD.BITCMP is reported for line 11: Questionable use of bit operation '&' in expression. Did you mean '&&'?

Related checkers