Class OpcodeStack
java.lang.Object
edu.umd.cs.findbugs.OpcodeStack
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceYou 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.(package private) static classstatic classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean(package private) int(package private) intprivate static final booleanprivate static final boolean(package private) boolean(package private) BitSetprivate Stringprivate static final Stringprivate static final Stringprivate Map<Integer, List<OpcodeStack.Item>> private BitSetprivate booleanprivate booleanprivate Map<Integer, List<OpcodeStack.Item>> private List<OpcodeStack.Item> private String(package private) boolean(package private) booleanprivate boolean(package private) intprivate booleanprivate List<OpcodeStack.Item> private booleanprivate final boolean(package private) DismantleBytecode(package private) int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddBoxedType(Class<?>... clss) private voidaddJumpValue(int from, int target) voidclear()(package private) void(package private) voidprivate static voidclearRegisterLoad(List<OpcodeStack.Item> list, int register) private doubleprivate floatprivate intprivate longprivate voideraseKnowledgeOf(XField fieldOperand) private org.apache.bcel.classfile.BootstrapMethodgetBootstrapMethod(org.apache.bcel.classfile.Attribute[] attribs, org.apache.bcel.classfile.Constant index) static StringgetExceptionSig(DismantleBytecode dbc, org.apache.bcel.classfile.CodeException e) private OpcodeStack.JumpInfointgetLastUpdate(int reg) getLVValue(int index) intintintgetStackItem(int stackOffset) private StringgetStringFromIndex(DismantleBytecode dbc, int i) private voidhandleDcmp(int opcode) private voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidhandleFcmp(int opcode) private voidprivate voidbooleanhasIncomingBranches(int pc) void(package private) booleanprotected booleanbooleanisJumpTarget(int pc) private booleanisMethodThatReturnsGivenReference(String clsName, String methodName) (package private) booleanbooleanisTop()voidprivate voidvoidprivate booleanmergeLists(List<OpcodeStack.Item> mergeInto, List<OpcodeStack.Item> mergeFrom, boolean errorIfSizesDoNotMatch) (package private) intnullSafeSize(Collection<?> c) private OpcodeStack.Itempop()private voidpop(int count) voidvoidprivate voidprivate voidprocessMethodCall(DismantleBytecode dbc, int seen) private voidprivate voidpushByConstant(DismantleBytecode dbc, org.apache.bcel.classfile.Constant c) private voidpushByDoubleMath(int seen, OpcodeStack.Item it, OpcodeStack.Item it2) private voidpushByFloatMath(int seen, OpcodeStack.Item it, OpcodeStack.Item it2) private voidpushByIntMath(DismantleBytecode dbc, int seen, OpcodeStack.Item lhs, OpcodeStack.Item rhs) private voidpushByInvoke(DismantleBytecode dbc, boolean popThis) private voidpushByLocalLoad(String signature, int register) private voidpushByLocalObjectLoad(DismantleBytecode dbc, int register) private voidpushByLocalStore(int register) private voidpushByLongMath(int seen, OpcodeStack.Item lhs, OpcodeStack.Item rhs) private voidpushBySignature(String s, DismantleBytecode dbc) voidreplace(int stackOffset, OpcodeStack.Item value) voidreplaceTop(OpcodeStack.Item newTop) intresetForMethodEntry(DismantleBytecode visitor) private intresetForMethodEntry0(PreorderVisitor visitor) (package private) intresetForMethodEntry0(String className, org.apache.bcel.classfile.Method m) voidsawOpcode(DismantleBytecode dbc, int seen) voidsetJumpInfoChangedByBackwardBranch(String kind, int from, int to) (package private) voidsetJumpInfoChangedByBackwardsBranch(int from, int to) protected voidprivate voidsetLastUpdate(int reg, int pc) private voidsetLVValue(int index, OpcodeStack.Item value) (package private) voidsetReachOnlyByBranch(boolean reachOnlyByBranch) private voidsetTop(boolean top) private OpcodeStack.Itemtop()toString()
-
Field Details
-
JAVA_UTIL_ARRAYS_ARRAY_LIST
- See Also:
-
JAVA_UTIL_COLLECTIONS
- See Also:
-
DEBUG
private static final boolean DEBUG -
DEBUG2
private static final boolean DEBUG2 -
IMMUTABLE_RETURNER_MAP
-
boxedTypes
-
stack
-
lvValues
-
lastUpdate
-
top
private boolean top -
seenTransferOfControl
private boolean seenTransferOfControl -
useIterativeAnalysis
private final boolean useIterativeAnalysis -
encountedTop
boolean encountedTop -
backwardsBranch
boolean backwardsBranch -
exceptionHandlers
BitSet exceptionHandlers -
jumpInfoChangedByBackwardsBranch
private boolean jumpInfoChangedByBackwardsBranch -
jumpInfoChangedByNewTarget
private boolean jumpInfoChangedByNewTarget -
jumpEntries
-
jumpStackEntries
-
jumpEntryLocations
-
convertJumpToOneZeroState
int convertJumpToOneZeroState -
convertJumpToZeroOneState
int convertJumpToZeroOneState -
registerTestedFoundToBeNonnegative
int registerTestedFoundToBeNonnegative -
zeroOneComing
int zeroOneComing -
oneMeansNull
boolean oneMeansNull -
needToMerge
boolean needToMerge -
reachOnlyByBranch
private boolean reachOnlyByBranch -
methodName
-
fullyQualifiedMethodName
-
v
-
-
Constructor Details
-
OpcodeStack
public OpcodeStack()
-
-
Method Details
-
toString
-
hasIncomingBranches
public boolean hasIncomingBranches(int pc) -
getExceptionSig
public static String getExceptionSig(DismantleBytecode dbc, org.apache.bcel.classfile.CodeException e) -
mergeJumps
-
setLastUpdate
private void setLastUpdate(int reg, int pc) -
getLastUpdate
public int getLastUpdate(int reg) -
getNumLastUpdates
public int getNumLastUpdates() -
sawOpcode
-
eraseKnowledgeOf
-
precomputation
-
constantToInt
-
constantToFloat
-
constantToDouble
-
constantToLong
-
handleDcmp
private void handleDcmp(int opcode) -
handleFcmp
private void handleFcmp(int opcode) -
handleLcmp
private void handleLcmp() -
handleSwap
private void handleSwap() -
handleDup
private void handleDup() -
handleDupX1
private void handleDupX1() -
handleDup2
private void handleDup2() -
handleDup2X1
private void handleDup2X1() -
handleDup2X2
private void handleDup2X2() -
handleDupX2
private void handleDupX2() -
addBoxedType
-
markConstantValueUnknown
-
processMethodCall
-
isMethodThatReturnsGivenReference
-
processInvokeDynamic
-
getBootstrapMethod
private org.apache.bcel.classfile.BootstrapMethod getBootstrapMethod(org.apache.bcel.classfile.Attribute[] attribs, org.apache.bcel.classfile.Constant index) -
mergeLists
private boolean mergeLists(List<OpcodeStack.Item> mergeInto, List<OpcodeStack.Item> mergeFrom, boolean errorIfSizesDoNotMatch) -
clear
public void clear() -
printJumpEntries
public void printJumpEntries() -
isJumpTarget
public boolean isJumpTarget(int pc) -
addJumpValue
private void addJumpValue(int from, int target) -
learnFrom
-
initialize
public void initialize() -
resetForMethodEntry
-
nullSafeSize
-
getJumpInfo
-
getJumpInfoFromStackMap
-
setJumpInfoChangedByBackwardBranch
-
resetForMethodEntry0
-
resetForMethodEntry0
-
getStackDepth
public int getStackDepth() -
getStackItem
-
pop
-
top
-
replace
-
replaceTop
-
pop
private void pop(int count) -
push
-
pushByConstant
-
pushByLocalObjectLoad
-
pushByIntMath
private void pushByIntMath(DismantleBytecode dbc, int seen, OpcodeStack.Item lhs, OpcodeStack.Item rhs) -
pushByLongMath
-
pushByFloatMath
-
pushByDoubleMath
-
pushByInvoke
-
getItemMethodInvokedOn
-
getStringFromIndex
-
pushBySignature
-
pushByLocalStore
private void pushByLocalStore(int register) -
clearRegisterLoad
-
pushByLocalLoad
-
setLVValue
-
getLVValue
-
getNumLocalValues
public int getNumLocalValues() -
setTop
private void setTop(boolean top) -
isTop
public boolean isTop() -
setReachOnlyByBranch
void setReachOnlyByBranch(boolean reachOnlyByBranch) -
isReachOnlyByBranch
boolean isReachOnlyByBranch() -
isJumpInfoChangedByBackwardsBranch
boolean isJumpInfoChangedByBackwardsBranch() -
clearJumpInfoChangedByBackwardsBranch
void clearJumpInfoChangedByBackwardsBranch() -
setJumpInfoChangedByBackwardsBranch
void setJumpInfoChangedByBackwardsBranch(int from, int to) -
isJumpInfoChangedByNewTarget
protected boolean isJumpInfoChangedByNewTarget()- Returns:
- Returns the jumpInfoChangedByNewTarget.
-
clearJumpInfoChangedByNewTarget
void clearJumpInfoChangedByNewTarget() -
setJumpInfoChangedByNewTarget
protected void setJumpInfoChangedByNewTarget()
-