SDA SE Wiki

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

User Tools

Site Tools


Bug Cor 86

Inspired by

Original Description

“This instanceof test will always return false, since the value being checked is guaranteed to be null. Although this is safe, make sure it isn't an indication of some misunderstanding or some other logic error. ” – 2013-12-16

Detailed Description

The value that is checked with an instanceOf operation is ensured to be null (With the help of points-to-analysis). Therefore, there is probably a logical error in the code. No sample fix can be given.

Sample Problem Scenario

<code Java>

if(a instanceof String){
  System.out.println("BUUG!");
}

</Code>

Sample Counter Scenario

<code Java>

private static Object returnsNotNull(){
  return new Object();
}
Object o = null;
o = returnsNotNull();
boolean b = o instanceof Object;
System.out.println(b);

</Code>

Sample Fix

No fix provided.

Evaluation Results

Benchmark project Precision Recall
FB JT Delta FB JT Delta
MDSE Lab 100% 66% - 66% 33% -%
Apache Tomcat 100% 100% 0 100% 100% 0%
Argo UML 100% 100% 0 100% 100% 0%
AWT 100% 100% 0 100% 100% 0%
Jakarta 100% 100% 0 100% 100% 0%
Java IO 100% 100% 0 100% 100% 0%
JHotDraw 100% 100% 0 100% 100% 0%
jrefactory 100% 100% 0 100% 100% 0%
JServlet 100% 100% 0 100% 100% 0%
JUnit 100% 100% 0 100% 100% 0%
Lexi 100% 100% 0 100% 100% 0%
Mapper XML 100% 100% 0 100% 100% 0%
nutch 100% 100% 0 100% 100% 0%
PMD 100% 100% 0 100% 100% 0%
quickuml 100% 100% 0 100% 100% 0%

FB = FindBugs, JT = JTransformer, Delta = JTransformer - FindBug

teaching/labs/mdse/2013/bug_descriptions/jt-bug-cor86.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2023