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
Last revision Both sides next revision
teaching:labs:mdse:2013:bug_descriptions:jt-bug-cor10 [2014/03/27 15:21]
malte.mauelshagen
teaching:labs:mdse:2013:bug_descriptions:jt-bug-cor10 [2018/05/09 01:59]
127.0.0.1 external edit
Line 1: Line 1:
 +====== Cor 10 ======
 +<note warning>
 +FindBugs does not detect this bug.
 +</​note>​
 +
 +
 +
 +===== Inspired by =====
 +
 +  * [[http://​findbugs.sourceforge.net/​bugDescriptions.html#​BIT_SIGNED_CHECK_HIGH_BIT | BIT: Check for sign of bitwise operation (BIT_SIGNED_CHECK_HIGH_BIT)]]
 +
 +===== Original Description =====
 +
 +" This method compares an expression such as
 +  ((event.detail & SWT.SELECTED) > 0)
 +Using bit arithmetic and then comparing with the greater than operator can lead to unexpected results (of course depending on the value of SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate for a bug. Even when SWT.SELECTED is not negative, it seems good practice to use '!= 0' instead of '> 0'.
 +
 +Boris Bokowski " -- 2013-10-31 ​
 +
 +===== Detailed Description =====
 +
 +When using bit arithmetic, it is impossible to get a negative number as a result. Therefore, all x > 0 expressions should be transformed into a x != 0 expression. This is more concise and will reduce confusion. In general (if comparing with another number than 0) the greater than operator is also unusual but possible in my opinion, stated the bit arithmetic is applied to bigger numbers.
 +
 + 
 +
 +===== Sample Problem Scenario =====
 +
 +
 +<code Java>
 + if ((x & y) > 0) {
 +
 + }
 +</​Code>​
 +
 +<code Java>
 + if ((4 & 5) > 0) {
 +
 + }
 +</​Code>​
 +
 +===== Sample Counter Scenario =====
 +
 +<code Java>
 + if ((x & y) > 3) {
 +
 + }
 +</​Code>​
 +
 +
 +===== Sample Fix =====
 +
 +<code Java>
 + if ((x & y) != 0) {
 +
 + }
 +</​Code>​
 +===== Evaluation Results =====
 +
 +
 +^  Benchmark project ​ ^ Time ^ # Hits ^^  Precision ​             ^^^  Recall ​               ^^^
 +|                     || FB | JT | FB    |  JT    |  Delta  |  FB    |  JT    |  Delta |
 +|  Apache Tomcat ​     |< 1s|0|0| 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +|  Argo UML           |< 1s|0|18| ​   100%  | 100%  |  0  |  100%  |  0%  |  100  |
 +|  AWT                |< 1s|0|1| ​ 100%  | 100%  |  0  |  100%  |  0%  |  100  | 
 +|  Jakarta ​           |< 1s|0|0| ​ 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +|  Java IO            |< 1s|0|0| ​ 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +|  JHotDraw ​          |< 1s|0|0| ​ 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +|  jrefactory ​        |< 1s|0|2| ​   100%  | 100%  |  0  |  100%  |  0%  |  100  | 
 +|  JServlet ​       |< 1s|0|0| 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +|  JUnit           |< 1s|0|0| 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +|  Lexi            |< 1s|0|0| 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +|  Mapper XML      |< 1s|0|0| 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +|  nutch           |< 1s|0|0| 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +|  PMD             |< 1s|0|13| 100%  | 100%  |  0  |  100%  |  0%  |  100  |  ​
 +|  quickuml ​       |< 1s|0|0| 100%  | 100%  |  0  |  100%  |  100%  |  0  |  ​
 +
 +FB = FindBugs, JT = JTransformer,​ Delta = JTransformer - FindBug
 +
 +All measurements were taken on a machine with the following properties:
 +  * JT Version: 4.0.0
 +  * Eclipse Kepler
 +  * Windows 8.1
 +  * i5 2,30Ghz
 +  * 8 GB Main Memory
 +  * SSD Hardrive
  
teaching/labs/mdse/2013/bug_descriptions/jt-bug-cor10.txt · Last modified: 2019/06/28 19:31 by Günter Kniesel

SEWiki, © 2019