SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
teaching:labs:mdse:2013:bug_descriptions:jt-bug-cor8 [2014/01/29 02:02]
127.0.0.1 external edit
teaching:labs:mdse:2013:bug_descriptions:jt-bug-cor8 [2018/05/09 01:59] (current)
Line 1: Line 1:
 +====== Bug Cor 8 ======
  
 +===== Inspired by =====
 +
 +  * [[http://​findbugs.sourceforge.net/​bugDescriptions.html#​BIT_OR | BIT: Incompatible bit masks (BIT_OR)]]
 +
 +===== Original Description =====
 +
 +"This method compares an expression of the form (e & C) to D, which will always compare unequal due to the specific values of constants C and D. This may indicate a logic error or typo.
 +
 +===== Detailed Description =====
 +
 +The bitwise [[http://​docs.oracle.com/​javase/​tutorial/​java/​nutsandbolts/​op3.html| OR operator: | ]], performs a disjunctive comparison between two integer numbers, bit by bit and returns the resulting integer. For example: ​
 +
 +<code Java>
 +short a = 11; // 00001011
 +short b = 33; // 00100001
 +short c = a | b; // 00101011
 +</​Code>​
 +
 +Would assign c, as result, the value: 43 (1 in binary). ​
 +
 +When the result of a bitwise |operation is compared with another value, which can be determined before runtime and one of the compared numbers can also be determined before runtime, it is possible to detect if the comparison will always evaluate to false. This is owning to the fact that, in order to produce a 0 at a particular bit, the OR operator requires that both of the corresponding bits in the parameters are 0. If this situation is detected, its very likely due to a logic error in the code or an incorrect usage of the AND operator where [[http://​docs.oracle.com/​javase/​tutorial/​java/​nutsandbolts/​op3.html| AND(&​)]] should have been used.
 +
 +===== Sample Problem Scenario =====
 +
 +<code Java>
 +public class BitwiseErrors {
 + int j =0;
 + 
 +
 + if ( (j | 0) == 1){                // The comparison will be unequal. ​
 + System.out.print("​Never printed"​);​
 + }else
 + {        ​
 + System.out.print("​Incompatible mask"​);​
 + }
 +
 +}
 +</​Code>​
 +
 +
 +===== Evaluation Results =====
 +
 +^  Benchmark project ​ ^  Precision ​             ^^^  Recall ​               ^^^
 +|                     ​| ​ FB    |  JT    |  Delta  |  FB    |  JT    |  Delta |
 +|  Project ...        |  ...%  |  ...%  |  ...%   ​| ​ ...%  |  ...%  |  ...%  |  ​
 +|  Project ...        |  ...%  |  ...%  |  ...%   ​| ​ ...%  |  ...%  |  ...%  |   
 +FB = FindBugs, JT = JTransformer,​ Delta = JTransformer - FindBugs
 + 
teaching/labs/mdse/2013/bug_descriptions/jt-bug-cor8.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019