Menu

#52 bugfix - NPE in SecondPassMethodInstrumenter

open
nobody
None
5
2006-12-03
2006-12-03
No

On some of my classes I was getting this:

java.lang.NullPointerException
at org.objectweb.asm.MethodWriter.visitLocalVariable(Unknown Source)
at net.sourceforge.cobertura.instrument.SecondPassMethodInstrumenter.vis
itMaxs(SecondPassMethodInstrumenter.java:362)
at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at net.sourceforge.cobertura.instrument.FirstPassMethodInstrumenter.visi
tEnd(FirstPassMethodInstrumenter.java:96)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)

An analysis showed that startLabel and endLabel were null in these cases. Staring at the code, it seems that these local variables aren't used/needed if startLabel & friends aren't initialized.

In this case, the attached patch should be harmless. In any case, it worked for me.

Discussion

  • Paul Mclachlan

    Paul Mclachlan - 2006-12-03

    simple patch for "if not null" ... logic in visitMaxs

     
  • Paul King

    Paul King - 2007-03-10

    Logged In: YES
    user_id=694119
    Originator: NO

    I was getting the same issue and this patch fixed the problem. +1 for adding this before next release.