tim_wonil tim_wonil - 4 years ago 201
Java Question

Findbugs reports an incompatible bit mask bug, but I don't see how

I have a Comparator that checks "null"s for the two objects before comparing their contents.
The compare method looks like this:

public int compare(MyClass left, MyClass right) {
if (left == null) {
return right == null ? 0 : 1;
}
if (right == null) {
return -1;
}
// do some other comparing
}


When I run this through sonar code quality checking tool, it reports "incompatible bit masks" error at the if statements. (It reads something like: "Correctness - Incompatible bit masks: Incompatible bit masks in (e | 0x1 = 0x0) yields constant result in ....Compare (MyClass, MyClass) I cannot see how this can be the case. Can anybody shed some light on this? Is this a false positive case?

By the way, The sonar version I am using is 2.6.

Answer Source

I believe i know what's going on. I believe your code is being weaved by Clover, and the clover code is embellishing that code and the way it does it is in a not so clean way.

44: sipush  14625
47: invokevirtual   #10; //Method com_cenqua_clover/CoverageRecorder.iget:(I)I
50: ifeq    57
53: iconst_1
54: goto    58
57: iconst_0
58: iconst_1
59: ior
60: ifne    85

That is what FindBugs is complaining about.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download