Menu

#57 Ignore branches on ignored lines

open
nobody
None
5
2007-07-31
2007-07-31
Sam
No

In my code base (java 1.4) we use a log class with an assert replacement along the lines of "Log.check(thingy != null)." If I use the "ignore" regex it ignores this line for purposes of counting but it still instruments the conditonals and marks them as untouched branches in the report (the counts are not affected however). I went into the 1.9 release source and created a patch that fixes this issue. I don;t have any SVN tools on my machine so its not easy for me to make a patch file but the fix is only 5 lines of code so it shouldn't be too difficult to do by hand. There may be a better way of handling this during reporting but this patch solved my problem.

FirstPassMethodInstrumenter.java{
//add a vector for holding current jumpLabels
Vector thisLineJumps = new Vector();
//in function visitJumpInsn(opcode, Label label){
//between classData.addLineJump() and jumpTargetLabels.put insert:
if(!thisLineJumps.contains(label)) thisLineJumps.add(label);
//}

//in function visitMethodInsn(){
//after classData.removeLine(currentLine);
for (int i = 0; i < thisLineJumps.size(); i++){
jumpTargetLabels.remove(thisLineJumps.elementAt(i));
}
//}
}
SecondPassMethodInstrumenter.java{
//in function vistJumpInsn(opcode,Label)
// after <clinit> check in if statment add:

}&& this.firstPass.getJumpTargetLabels().containsKey(label)

Discussion