Class TernaryPatcher

java.lang.Object
com.mebigfatguy.fbcontrib.utils.TernaryPatcher

public final class TernaryPatcher extends Object
restores OpcodeStack Item's userValues when a ternary is processed. This class is required because Findbugs has a bug whereby it strips the user value field from all OpcodeStack items when a GOTO is processed when items are on the stack. Normally this is not the case, but in the case of ternary handling there may be N items on the stack before what the ternary pushes. Now clearly the uservalue should be stripped for items pushed on by both branches of the ternary, but items that were on the stack before the ternary was executed should be left alone. This is currently not happening in findbugs. So this class saves off user values across a GOTO involved with a ternary and restores them appropriately.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static boolean
     
    private static List<Object>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    post(edu.umd.cs.findbugs.OpcodeStack stack, int opcode)
    called after the execution of the parent OpcodeStack.sawOpcode, to restore the user values after the GOTO or GOTO_W's mergeJumps were processed
    static void
    pre(edu.umd.cs.findbugs.OpcodeStack stack, int opcode)
    called before the execution of the parent OpcodeStack.sawOpcode() to save user values if the opcode is a GOTO or GOTO_W.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • userValues

      private static List<Object> userValues
    • sawGOTO

      private static boolean sawGOTO
  • Constructor Details

    • TernaryPatcher

      private TernaryPatcher()
  • Method Details

    • pre

      public static void pre(edu.umd.cs.findbugs.OpcodeStack stack, int opcode)
      called before the execution of the parent OpcodeStack.sawOpcode() to save user values if the opcode is a GOTO or GOTO_W.
      Parameters:
      stack - the OpcodeStack with the items containing user values
      opcode - the opcode currently seen
    • post

      public static void post(edu.umd.cs.findbugs.OpcodeStack stack, int opcode)
      called after the execution of the parent OpcodeStack.sawOpcode, to restore the user values after the GOTO or GOTO_W's mergeJumps were processed
      Parameters:
      stack - the OpcodeStack with the items containing user values
      opcode - the opcode currently seen