SDA SE Wiki

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

User Tools

Site Tools


Bug Cor 24

Inspired by

Original Description

“The Double.longBitsToDouble method is invoked, but a 32 bit int value is passed as an argument. This almostly certainly is not intended and is unlikely to give the intended result. ” – 2013-11-25

Detailed Description

The method Double.longBitsToDouble(long l) does not complain if you pass an int value instead of a long value since, in general, longs can be constructed out of ints. In this case though not the value but the bits are important, therefore the constructed long might have a different effect as intended.

In any case one should never pass an int to this method. There is no good fix for this, that's why we don't offer one.

Sample Problem Scenario

<code Java>

int i = 1003;
System.out.println(Double.longBitsToDouble(i));

Integer ii = new Integer(123);
System.out.println(Double.longBitsToDouble(ii));

</Code>

Sample Counter Scenario

<code Java>

long l = 1003;
System.out.println(Double.longBitsToDouble(l));

</Code>

Evaluation Results

Benchmark project Time # Hits Precision Recall
FB JT FB JT Delta FB JT Delta
Apache Tomcat < 1s00 100% 100% 0 100% 100% 0
Argo UML < 1s00 100% 100% 0 100% 100% 0
AWT < 1s00 100% 100% 0 100% 100% 0
Jakarta < 1s00 100% 100% 0 100% 100% 0
Java IO < 1s00 100% 100% 0 100% 100% 0
JHotDraw < 1s00 100% 100% 0 100% 100% 0
jrefactory < 1s00 100% 100% 0 100% 100% 0
JServlet < 1s00 100% 100% 0 100% 100% 0
JUnit < 1s00 100% 100% 0 100% 100% 0
Lexi < 1s00 100% 100% 0 100% 100% 0
Mapper XML < 1s00 100% 100% 0 100% 100% 0
nutch < 1s00 100% 100% 0 100% 100% 0
PMD < 1s00 100% 100% 0 100% 100% 0
quickuml < 1s00 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-cor24.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2024