Package edu.umd.cs.findbugs
Class OpcodeStack.Item
- java.lang.Object
-
- edu.umd.cs.findbugs.OpcodeStack.Item
-
- Enclosing class:
- OpcodeStack
public static class OpcodeStack.Item extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceOpcodeStack.Item.SpecialKindA type qualifier to markintvalue as SpecialKind type.
-
Field Summary
Fields Modifier and Type Field Description static intAVERAGE_COMPUTED_USING_DIVISIONprivate java.lang.ObjectconstValueprivate static intCOULD_BE_ZERO_FLAGprivate intfieldLoadedFromRegisterstatic intFILE_OPENED_IN_APPEND_MODEstatic intFILE_SEPARATOR_STRINGprivate intflagsstatic intFLOAT_MATHstatic intHASHCODE_INTstatic intHASHCODE_INT_REMAINDERprivate OpcodeStack.HttpParameterInjectioninjectionstatic intINTEGER_SUMprivate static intIS_INITIAL_PARAMETER_FLAGprivate static intIS_NULL_FLAGstatic intLOW_8_BITS_CLEARstatic intMATH_ABSstatic intMATH_ABS_OF_HASHCODEstatic intMATH_ABS_OF_RANDOMstatic intNASTY_FLOAT_MATHstatic intNEWLY_ALLOCATEDprivate static java.util.concurrent.atomic.AtomicIntegernextSpecialKindstatic intNON_NEGATIVEstatic intNONZERO_MEANS_NULLstatic intNOT_SPECIALprivate intpcstatic intRANDOM_INTstatic intRANDOM_INT_REMAINDERprivate intregisterNumberstatic intRESULT_OF_I2Lstatic intRESULT_OF_L2Istatic intSERVLET_OUTPUTstatic intSERVLET_REQUEST_TAINTEDprivate java.lang.Stringsignaturestatic intSIGNED_BYTEprivate ClassMembersourceprivate intspecialKindprivate static java.util.concurrent.ConcurrentMap<java.lang.Integer,java.lang.String>specialKindToNamestatic intTYPE_ONLYstatic java.lang.ObjectUNKNOWNprivate java.lang.ObjectuserValuestatic intZERO_MEANS_NULL
-
Constructor Summary
Constructors Constructor Description Item()Item(OpcodeStack.Item it)Item(OpcodeStack.Item it, int reg)Item(OpcodeStack.Item it, java.lang.String signature)Item(java.lang.String signature)Item(java.lang.String signature, int constValue)Item(java.lang.String signature, FieldAnnotation f)Item(java.lang.String signature, FieldAnnotation f, int fieldLoadedFromRegister)Item(java.lang.String signature, java.lang.Object constantValue)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description (package private) static intasSpecialKind(int kind)booleancheckForIntegerMinValue()Value could be Integer.MIN_VALUEvoidclearNewlyAllocated()OpcodeStack.ItemcloneAndSetSpecialKind(int specialKind)booleancouldBeZero()static intdefineSpecialKind(java.lang.String name)Define a new special kind and name it as specified.booleanequals(java.lang.Object o)java.lang.ObjectgetConstant()Returns a constant value for this Item, if known.java.lang.StringgetElementSignature()Deprecated.FieldAnnotationgetFieldAnnotation()Deprecated.intgetFieldLoadedFromRegister()If this value was loaded from an instance field, give the register number containing the object that the field was loaded from.java.lang.StringgetHttpParameterName()intgetInjectionPC()org.apache.bcel.classfile.JavaClassgetJavaClass()Returns null for primitive and arraysintgetPC()intgetRegisterNumber()XMethodgetReturnValueOf()java.lang.StringgetSignature()intgetSize()intgetSpecialKind()intgetSpecialKindForAbs()intgetSpecialKindForRemainder()static java.util.Optional<java.lang.String>getSpecialKindName(int specialKind)java.lang.ObjectgetUserValue()gets the detector specified value for this itemXFieldgetXField()booleanhasConstantValue(int value)booleanhasConstantValue(long value)inthashCode()static OpcodeStack.IteminitialArgument(java.lang.String signature, int reg)booleanisArray()booleanisBooleanNullnessValue()private booleanisCouldBeZero()booleanisInitialParameter()booleanisNewlyAllocated()booleanisNonNegative()booleanisNull()booleanisPrimitive()booleanisServletParameterTainted()booleanisServletWriter()booleanisWide()private booleanisZero()voidmakeCrossMethod()static OpcodeStack.Itemmerge(OpcodeStack.Item i1, OpcodeStack.Item i2)booleanmightRarelyBeNegative()The result of applying Math.abs to a checkForIntegerMinValue() valuebooleanmustBeZero()static OpcodeStack.ItemnullItem(java.lang.String signature)booleansameValue(OpcodeStack.Item that)voidsetCouldBeNegative()private voidsetCouldBeZero(boolean couldBeZero)private voidsetFlag(boolean value, int flagBit)private voidsetInitialParameter(boolean isInitialParameter)voidsetIsServletWriter()voidsetLoadedFromField(XField f, int fieldLoadedFromRegister)private voidsetNull(boolean isNull)voidsetPC(int pc)voidsetServletParameterTainted()voidsetSpecialKind(int specialKind)private voidsetSpecialKindFromSignature()voidsetUserValue(java.lang.Object value)attaches a detector specified value to this itemjava.lang.StringtoString()static OpcodeStack.ItemtypeOnly(java.lang.String signature)booleanusesTwoSlots()booleanvalueCouldBeNegative()
-
-
-
Field Detail
-
NOT_SPECIAL
@SpecialKind public static final int NOT_SPECIAL
- See Also:
- Constant Field Values
-
SIGNED_BYTE
@SpecialKind public static final int SIGNED_BYTE
- See Also:
- Constant Field Values
-
RANDOM_INT
@SpecialKind public static final int RANDOM_INT
- See Also:
- Constant Field Values
-
LOW_8_BITS_CLEAR
@SpecialKind public static final int LOW_8_BITS_CLEAR
- See Also:
- Constant Field Values
-
HASHCODE_INT
@SpecialKind public static final int HASHCODE_INT
- See Also:
- Constant Field Values
-
INTEGER_SUM
@SpecialKind public static final int INTEGER_SUM
- See Also:
- Constant Field Values
-
AVERAGE_COMPUTED_USING_DIVISION
@SpecialKind public static final int AVERAGE_COMPUTED_USING_DIVISION
- See Also:
- Constant Field Values
-
FLOAT_MATH
@SpecialKind public static final int FLOAT_MATH
- See Also:
- Constant Field Values
-
RANDOM_INT_REMAINDER
@SpecialKind public static final int RANDOM_INT_REMAINDER
- See Also:
- Constant Field Values
-
HASHCODE_INT_REMAINDER
@SpecialKind public static final int HASHCODE_INT_REMAINDER
- See Also:
- Constant Field Values
-
FILE_SEPARATOR_STRING
@SpecialKind public static final int FILE_SEPARATOR_STRING
- See Also:
- Constant Field Values
-
MATH_ABS
@SpecialKind public static final int MATH_ABS
- See Also:
- Constant Field Values
-
MATH_ABS_OF_RANDOM
@SpecialKind public static final int MATH_ABS_OF_RANDOM
- See Also:
- Constant Field Values
-
MATH_ABS_OF_HASHCODE
@SpecialKind public static final int MATH_ABS_OF_HASHCODE
- See Also:
- Constant Field Values
-
NON_NEGATIVE
@SpecialKind public static final int NON_NEGATIVE
- See Also:
- Constant Field Values
-
NASTY_FLOAT_MATH
@SpecialKind public static final int NASTY_FLOAT_MATH
- See Also:
- Constant Field Values
-
FILE_OPENED_IN_APPEND_MODE
@SpecialKind public static final int FILE_OPENED_IN_APPEND_MODE
- See Also:
- Constant Field Values
-
SERVLET_REQUEST_TAINTED
@SpecialKind public static final int SERVLET_REQUEST_TAINTED
- See Also:
- Constant Field Values
-
NEWLY_ALLOCATED
@SpecialKind public static final int NEWLY_ALLOCATED
- See Also:
- Constant Field Values
-
ZERO_MEANS_NULL
@SpecialKind public static final int ZERO_MEANS_NULL
- See Also:
- Constant Field Values
-
NONZERO_MEANS_NULL
@SpecialKind public static final int NONZERO_MEANS_NULL
- See Also:
- Constant Field Values
-
RESULT_OF_I2L
@SpecialKind public static final int RESULT_OF_I2L
- See Also:
- Constant Field Values
-
RESULT_OF_L2I
@SpecialKind public static final int RESULT_OF_L2I
- See Also:
- Constant Field Values
-
SERVLET_OUTPUT
@SpecialKind public static final int SERVLET_OUTPUT
- See Also:
- Constant Field Values
-
TYPE_ONLY
@SpecialKind public static final int TYPE_ONLY
- See Also:
- Constant Field Values
-
specialKindToName
@StaticConstant private static final java.util.concurrent.ConcurrentMap<java.lang.Integer,java.lang.String> specialKindToName
-
nextSpecialKind
private static java.util.concurrent.atomic.AtomicInteger nextSpecialKind
-
IS_INITIAL_PARAMETER_FLAG
private static final int IS_INITIAL_PARAMETER_FLAG
- See Also:
- Constant Field Values
-
COULD_BE_ZERO_FLAG
private static final int COULD_BE_ZERO_FLAG
- See Also:
- Constant Field Values
-
IS_NULL_FLAG
private static final int IS_NULL_FLAG
- See Also:
- Constant Field Values
-
UNKNOWN
public static final java.lang.Object UNKNOWN
-
specialKind
@SpecialKind private int specialKind
-
signature
private java.lang.String signature
-
constValue
private java.lang.Object constValue
-
source
@CheckForNull private ClassMember source
-
pc
private int pc
-
flags
private int flags
-
registerNumber
private int registerNumber
-
userValue
@Nullable private java.lang.Object userValue
-
injection
private OpcodeStack.HttpParameterInjection injection
-
fieldLoadedFromRegister
private int fieldLoadedFromRegister
-
-
Constructor Detail
-
Item
public Item(java.lang.String signature, int constValue)
-
Item
public Item(java.lang.String signature)
-
Item
public Item(OpcodeStack.Item it)
-
Item
public Item(OpcodeStack.Item it, java.lang.String signature)
-
Item
public Item(OpcodeStack.Item it, int reg)
-
Item
public Item(java.lang.String signature, FieldAnnotation f)
-
Item
public Item(java.lang.String signature, FieldAnnotation f, int fieldLoadedFromRegister)
-
Item
public Item(java.lang.String signature, java.lang.Object constantValue)
-
Item
public Item()
-
-
Method Detail
-
asSpecialKind
@SpecialKind static int asSpecialKind(int kind)
-
makeCrossMethod
public void makeCrossMethod()
-
getSize
public int getSize()
-
getPC
public int getPC()
-
setPC
public void setPC(int pc)
-
isWide
public boolean isWide()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
usesTwoSlots
public boolean usesTwoSlots()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
sameValue
public boolean sameValue(OpcodeStack.Item that)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
merge
public static OpcodeStack.Item merge(OpcodeStack.Item i1, OpcodeStack.Item i2)
-
initialArgument
public static OpcodeStack.Item initialArgument(java.lang.String signature, int reg)
-
typeOnly
public static OpcodeStack.Item typeOnly(java.lang.String signature)
-
getFieldLoadedFromRegister
public int getFieldLoadedFromRegister()
If this value was loaded from an instance field, give the register number containing the object that the field was loaded from. If Integer.MAX value, the value was loaded from a static field If -1, we don't know or don't have the register containing the object that the field was loaded from.
-
setLoadedFromField
public void setLoadedFromField(XField f, int fieldLoadedFromRegister)
-
getHttpParameterName
@CheckForNull public java.lang.String getHttpParameterName()
-
getInjectionPC
public int getInjectionPC()
-
setSpecialKindFromSignature
private void setSpecialKindFromSignature()
-
setCouldBeNegative
public void setCouldBeNegative()
-
nullItem
public static OpcodeStack.Item nullItem(java.lang.String signature)
-
getJavaClass
@CheckForNull public org.apache.bcel.classfile.JavaClass getJavaClass() throws java.lang.ClassNotFoundExceptionReturns null for primitive and arrays- Throws:
java.lang.ClassNotFoundException
-
isArray
public boolean isArray()
-
getElementSignature
@Deprecated public java.lang.String getElementSignature()
Deprecated.
-
isNonNegative
public boolean isNonNegative()
-
isPrimitive
public boolean isPrimitive()
-
getRegisterNumber
public int getRegisterNumber()
-
getSignature
public java.lang.String getSignature()
-
getConstant
public java.lang.Object getConstant()
Returns a constant value for this Item, if known. NOTE: if the value is a constant Class object, the constant value returned is the name of the class. if the value is an array of known length, the constant value returned is its length (Integer)
-
getFieldAnnotation
@Deprecated public FieldAnnotation getFieldAnnotation()
Deprecated.Use getXField instead
-
getXField
public XField getXField()
-
setSpecialKind
public void setSpecialKind(@SpecialKind int specialKind)
- Parameters:
specialKind- The specialKind to set.
-
cloneAndSetSpecialKind
public OpcodeStack.Item cloneAndSetSpecialKind(@SpecialKind int specialKind)
-
getSpecialKind
@SpecialKind public int getSpecialKind()
- Returns:
- Returns the specialKind.
-
isBooleanNullnessValue
public boolean isBooleanNullnessValue()
- Returns:
- Returns the specialKind.
-
setUserValue
public void setUserValue(@Nullable java.lang.Object value)attaches a detector specified value to this item
to use this method, detector should be annotated with
CustomUserValue.- Parameters:
value- the custom value to set- See Also:
OpcodeStack.CustomUserValue
-
getReturnValueOf
@CheckForNull public XMethod getReturnValueOf()
- Returns:
- if this value is the return value of a method, give the method invoked
-
couldBeZero
public boolean couldBeZero()
-
mustBeZero
public boolean mustBeZero()
-
getUserValue
@Nullable public java.lang.Object getUserValue()
gets the detector specified value for this item- Returns:
- the custom value
-
isServletParameterTainted
public boolean isServletParameterTainted()
-
setServletParameterTainted
public void setServletParameterTainted()
-
setIsServletWriter
public void setIsServletWriter()
-
isServletWriter
public boolean isServletWriter()
-
valueCouldBeNegative
public boolean valueCouldBeNegative()
-
getSpecialKindForAbs
@SpecialKind public int getSpecialKindForAbs()
-
getSpecialKindForRemainder
@SpecialKind public int getSpecialKindForRemainder()
-
checkForIntegerMinValue
public boolean checkForIntegerMinValue()
Value could be Integer.MIN_VALUE
-
mightRarelyBeNegative
public boolean mightRarelyBeNegative()
The result of applying Math.abs to a checkForIntegerMinValue() value
-
setInitialParameter
private void setInitialParameter(boolean isInitialParameter)
- Parameters:
isInitialParameter- The isInitialParameter to set.
-
isInitialParameter
public boolean isInitialParameter()
- Returns:
- Returns the isInitialParameter.
-
setCouldBeZero
private void setCouldBeZero(boolean couldBeZero)
- Parameters:
couldBeZero- The couldBeZero to set.
-
isCouldBeZero
private boolean isCouldBeZero()
- Returns:
- Returns the couldBeZero.
-
isZero
private boolean isZero()
-
setNull
private void setNull(boolean isNull)
- Parameters:
isNull- The isNull to set.
-
setFlag
private void setFlag(boolean value, int flagBit)
-
isNull
public boolean isNull()
- Returns:
- Returns the isNull.
-
clearNewlyAllocated
public void clearNewlyAllocated()
-
isNewlyAllocated
public boolean isNewlyAllocated()
-
hasConstantValue
public boolean hasConstantValue(int value)
-
hasConstantValue
public boolean hasConstantValue(long value)
-
defineSpecialKind
@SpecialKind public static int defineSpecialKind(java.lang.String name)
Define a new special kind and name it as specified.- Parameters:
name- Name of new special kind- Returns:
- int value to represent new special kind
- Since:
- 3.1.0
-
getSpecialKindName
public static java.util.Optional<java.lang.String> getSpecialKindName(@SpecialKind int specialKind)
- Parameters:
specialKind- special kind to get name- Returns:
- just a name of specified @{link SpecialKind}, or empty
Optional. - Since:
- 3.1.0
-
-