#1258 StringIndexOutOfBoundsException in PreorderVisitor.getNumberArguments

3.0.0
closed-rejected
None
5
2014-04-26
2014-03-20
J. Stolze
No

The PreorderVisitor.getNumberArguments method gives a
StringIndexOutOfBoundsException when analysing the signature:
Ljava/io/PrintStream;

I have written my own custom FB detector which detects if System.out is used in methods where loggers should be used instead. But when I create a new BugInstance and calling the method addCalledMethod than a StringIndexOutOfBoundsException fires.

java.lang.StringIndexOutOfBoundsException: String index out of range: 21
At java.lang.String.charAt(String.java:658)
At edu.umd.cs.findbugs.visitclass.PreorderVisitor.getNumberArguments(PreorderVisitor.java:560)
At edu.umd.cs.findbugs.MethodAnnotation.fromCalledMethod(MethodAnnotation.java:149)
At edu.umd.cs.findbugs.BugInstance.addCalledMethod(BugInstance.java:1622)

The analysed code looks like:

class FbTest {
void useLoggersHere() {
System.out.println("System.out is not allowed to be used here.");
}
}

My detector is extending the OpcodeStackDetector.

Discussion

  • I think the signature "Ljava/io/PrintStream;" you are returning from visitor.getSigConstantOperand() is not a valid method signature (it is field signature). So this is most likely bug in your custom detector.

    Regards,
    Andrey

     
    • status: open --> pending-rejected
    • assigned_to: Andrey Loskutov
     
    • status: pending-rejected --> closed-rejected