tags:

views:

36

answers:

1

I'm using a class that extends BytecodeScanningDetector to check for some problematic fields in a class. After detecting whether the field is problematic, I add it to the bug report like below: Once I run findbugs, it identifies the bug, lists it in the left pane, but does not highlight the corresponding source line.

Any hints/help on this will be very appreciated.

public void visit(Field f) { 
            if (isProblematic(getXField())) { 
                    bugReporter.reportBug(new BugInstance(this, 
                                                     tBugType, 
                                                      HIGH_PRIORITY) 
                                                     .addClass(currentClass) //from visit(JavaClass) 
                                                     .addField(this)); 
            } 
} 
public void visit(JavaClass someObj) { 
            currentClass = someObj.getClassName(); 
}

P.S. I tried posting this on the findbugs list but... no joy.

A: 

Unfortunately the java class file format does not associate line numbers with fields. The 'Line number table' attribute is an attribute of methods only. And so you can't do what you want to do.

MeBigFatGuy
this is sadly, very true.
Ryan Fernandes