SDA SE WikiSoftware Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
Format string placeholder incompatible with passed argument (VA_FORMAT_STRING_BAD_ARGUMENT)
“The format string placeholder is incompatible with the corresponding argument. For example, System.out.printf(”%d\n“, “hello”); The %d placeholder requires a numeric argument, but a string value is passed instead. A runtime exception will occur when this statement is executed.” – 2013-12-02
If the format string passed to the printf() method is not compatible with the argument in printf() method, it should detect the error at compilation time instead of throwing run-time exception (which is currently done by IDE).
class Sample {
public static void main(String[] args){
System.out.printf("%d\n","hello");
}
}
It is possible to correct the code by replacing the format string with correct one as shown in following example
class Sample {
public static void main(String[] args){
System.out.printf("%s\n","hello");
}
}
| Benchmark project | Precision | Recall | ||||
|---|---|---|---|---|---|---|
| FB | JT | Delta | FB | JT | Delta | |
| Project … | …% | …% | …% | …% | …% | …% |
| Project … | …% | …% | …% | …% | …% | …% |
FB = FindBugs, JT = JTransformer, Delta = JTransformer - FindBugs