Class OpcodeStack

java.lang.Object
edu.umd.cs.findbugs.OpcodeStack

public class OpcodeStack extends Object
tracks the types and numbers of objects that are currently on the operand stack throughout the execution of method. To use, a detector should instantiate one for each method, and call

stack.sawOpcode(this,seen);

at the bottom of their sawOpcode method. at any point you can then inspect the stack and see what the types of objects are on the stack, including constant values if they were pushed. The types described are of course, only the static types. There are some outstanding opcodes that have yet to be implemented, I couldn't find any code that actually generated these, so i didn't put them in because I couldn't test them:
  • dup2_x2
  • jsr_w
  • wide
  • Constructor Details

    • OpcodeStack

      public OpcodeStack()
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hasIncomingBranches

      public boolean hasIncomingBranches(int pc)
    • getExceptionSig

      public static String getExceptionSig(DismantleBytecode dbc, org.apache.bcel.classfile.CodeException e)
    • mergeJumps

      public void mergeJumps(DismantleBytecode dbc)
    • getLastUpdate

      public int getLastUpdate(int reg)
    • getNumLastUpdates

      public int getNumLastUpdates()
    • sawOpcode

      public void sawOpcode(DismantleBytecode dbc, int seen)
    • precomputation

      public void precomputation(DismantleBytecode dbc)
    • clear

      public void clear()
    • printJumpEntries

      public void printJumpEntries()
    • isJumpTarget

      public boolean isJumpTarget(int pc)
    • learnFrom

      public void learnFrom(OpcodeStack.JumpInfo info)
    • initialize

      public void initialize()
    • resetForMethodEntry

      public int resetForMethodEntry(DismantleBytecode visitor)
    • setJumpInfoChangedByBackwardBranch

      public void setJumpInfoChangedByBackwardBranch(String kind, int from, int to)
    • getStackDepth

      public int getStackDepth()
    • getStackItem

      public OpcodeStack.Item getStackItem(int stackOffset)
    • replace

      public void replace(int stackOffset, OpcodeStack.Item value)
    • replaceTop

      public void replaceTop(OpcodeStack.Item newTop)
    • getItemMethodInvokedOn

      public OpcodeStack.Item getItemMethodInvokedOn(DismantleBytecode dbc)
    • getLVValue

      @Nonnull public OpcodeStack.Item getLVValue(int index)
    • getNumLocalValues

      public int getNumLocalValues()
    • isTop

      public boolean isTop()
    • isJumpInfoChangedByNewTarget

      protected boolean isJumpInfoChangedByNewTarget()
      Returns:
      Returns the jumpInfoChangedByNewTarget.
    • setJumpInfoChangedByNewTarget

      protected void setJumpInfoChangedByNewTarget()