SDA SE Wiki

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

User Tools

Site Tools


Bug 048

Replace all placeholder words (written with underscores) by their suitable counterparts in the context of your Bug.

Inspired by

Original Description

“One of the arguments is incompatible with the corresponding format string specifier. As a result, this will generate a run-time exception when executed. For example, String.format(”%d“, “1”) will generate an exception, since the String “1” is incompatible with the format specifier %d.” – 2013-12-02

Detailed Description

Due to incompatible format specifier for integer and float, during the execution of the program it generates run-time exception. Whereas the IDE does not recognize the error.

Sample Problem Scenario

<code Java>

public static void main(String[] args) {
	String.format("%d","1");
	String.format("%f","1");
	String.format("%d", 1.5);
	
}

</Code>

Sample Fix

Change the format specifier according to the given argument <code Java>

public static void main(String[] args) {
              String.format("%s","1");
              String.format("%s","1");
        String.format("%f", 1.5);
	
}

</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-cor048.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2023