Package edu.umd.cs.findbugs
Class OpcodeStack
- java.lang.Object
-
- edu.umd.cs.findbugs.OpcodeStack
-
public class OpcodeStack extends java.lang.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 callstack.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
OpcodeStack.CustomUserValue
You can put this annotation on a OpcodeStack detector to indicate that it usesOpcodeStack.Item.userValue
, and thus should not reuse generic OpcodeStack information from an iterative evaluation of the opcode stack.static class
OpcodeStack.Item
static class
OpcodeStack.JumpInfo
static class
OpcodeStack.JumpInfoFactory
-
Constructor Summary
Constructors Constructor Description OpcodeStack()
-
Method Summary
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hasIncomingBranches
public boolean hasIncomingBranches(int pc)
-
getExceptionSig
public static java.lang.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(java.lang.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()
-
-