Package com.mebigfatguy.fbcontrib.detect
Class MissingMethodsDetector
java.lang.Object
edu.umd.cs.findbugs.visitclass.BetterVisitor
edu.umd.cs.findbugs.visitclass.PreorderVisitor
edu.umd.cs.findbugs.visitclass.AnnotationVisitor
edu.umd.cs.findbugs.visitclass.DismantleBytecode
edu.umd.cs.findbugs.BytecodeScanningDetector
com.mebigfatguy.fbcontrib.detect.MissingMethodsDetector
- All Implemented Interfaces:
edu.umd.cs.findbugs.Detector,edu.umd.cs.findbugs.Priorities,org.apache.bcel.classfile.Visitor
- Direct Known Subclasses:
HttpClientProblems,WriteOnlyCollection
public abstract class MissingMethodsDetector
extends edu.umd.cs.findbugs.BytecodeScanningDetector
an abstract base class for WriteOnlyCollections and HttpClientProblems, looks
for calls that are expected to be made, but are not.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final edu.umd.cs.findbugs.BugReporterprivate Stringprivate Stringfieldname to field sigprivate booleanprivate Map<Integer, MissingMethodsDetector.LocalUse> register to first allocation PCprivate Stringprivate booleanprivate edu.umd.cs.findbugs.OpcodeStackFields inherited from class edu.umd.cs.findbugs.visitclass.DismantleBytecode
codeBytes, lineNumberTable, M_BR, M_CP, M_INT, M_PAD, M_R, M_UINTFields inherited from interface edu.umd.cs.findbugs.Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMissingMethodsDetector(edu.umd.cs.findbugs.BugReporter bugReporter) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprotected voidclearSpecialField(String name) informs the missing method detector that a field should no longer be considered specialprivate voidclearUserValue(edu.umd.cs.findbugs.OpcodeStack.Item item) protected abstract booleanprotected abstract booleandoesStaticFactoryReturnNeedToBeWatched(String clsName, String methodName, String signature) protected Stringprotected edu.umd.cs.findbugs.OpcodeStackgetStack()private voidhandleTernary(int seen) protected abstract booleanisMethodThatShouldBeCalled(String methodName) protected abstract edu.umd.cs.findbugs.BugInstanceprotected abstract edu.umd.cs.findbugs.BugInstanceprivate booleanprotected voidChecks to see if any of the locals or fields that we are tracking are passed into another method.protected voidsaveSpecialFieldUse(String owningClassName, String fieldName, String signature) private voidsawAStore(int seen) private ObjectsawGetField(Object userObject) private ObjectsawGetStatic(Object userObject) private voidprivate ObjectsawInvokeSpecial(Object userObject) private ObjectsawInvokeStatic(Object userObject) private ObjectvoidsawOpcode(int seen) overrides the visitor to look for uses of collections where the only access to to the collection is to write to itprivate voidprivate voidvoidvisitClassContext(edu.umd.cs.findbugs.ba.ClassContext classContext) overrides the visitor to initialize and tear down the opcode stackvoidvisitCode(org.apache.bcel.classfile.Code obj) overrides the visitor reset the stackvoidvisitField(org.apache.bcel.classfile.Field obj) Methods inherited from class edu.umd.cs.findbugs.BytecodeScanningDetector
getClassContext, report, shouldVisitCodeMethods inherited from class edu.umd.cs.findbugs.visitclass.DismantleBytecode
afterOpcode, areOppositeBranches, atCatchBlock, beforeOpcode, getBranchFallThrough, getBranchOffset, getBranchTarget, getClassConstantOperand, getClassDescriptorOperand, getCodeByte, getConstantRefOperand, getDefaultSwitchOffset, getDottedClassConstantOperand, getFieldDescriptorOperand, getIntConstant, getLongConstant, getMaxPC, getMethodDescriptorOperand, getNameConstantOperand, getNextCodeByte, getNextOpcode, getNextPC, getOpcode, getPC, getPrevOpcode, getRefConstantOperand, getRefFieldIsStatic, getRegisterOperand, getSigConstantOperand, getStringConstantOperand, getSwitchLabels, getSwitchOffsets, getXClassOperand, getXFieldOperand, getXMethodOperand, isBranch, isMethodCall, isRegisterLoad, isRegisterStore, isRegisterStore, isReturn, isShift, isSwitch, isWideOpcode, printOpCode, sawBranchTo, sawClass, sawDouble, sawField, sawFloat, sawIMethod, sawInt, sawLong, sawMethod, sawRegister, sawString, visitMethods inherited from class edu.umd.cs.findbugs.visitclass.AnnotationVisitor
getAnnotationParameterAsEnum, getAnnotationParameterAsString, getAnnotationParameterAsStringArray, visitAnnotation, visitAnnotation, visitParameterAnnotation, visitParameterAnnotation, visitSyntheticParameterAnnotationMethods inherited from class edu.umd.cs.findbugs.visitclass.PreorderVisitor
amVisitingMainMethod, asUnsignedByte, doVisitMethod, getClassDescriptor, getClassName, getCode, getConstantPool, getDottedClassName, getDottedFieldSig, getDottedMethodSig, getDottedSuperclassName, getField, getFieldDescriptor, getFieldIsStatic, getFieldName, getFieldSig, getFullyQualifiedFieldName, getFullyQualifiedMethodName, getMethod, getMethodDescriptor, getMethodName, getMethodSig, getMethodVisitOrder, getNumberArguments, getNumberMethodArguments, getPackageName, getSizeOfSurroundingTryBlock, getSizeOfSurroundingTryBlock, getSourceFile, getStringFromIndex, getSuperclassName, getSurroundingCaughtExceptions, getSurroundingCaughtExceptions, getSurroundingCaughtExceptionTypes, getSurroundingTryBlock, getSurroundingTryBlock, getThisClass, getXClass, getXField, getXMethod, hasInterestingClass, hasInterestingMethod, isVisitMethodsInCallOrder, setupVisitorForClass, setVisitMethodsInCallOrder, shouldVisit, toString, visitAfter, visitAfter, visitAnnotationDefault, visitAnnotationEntry, visitBootstrapMethods, visitConstantInvokeDynamic, visitConstantMethodHandle, visitConstantMethodType, visitConstantModule, visitConstantPackage, visitConstantPool, visitEnclosingMethod, visitingField, visitingMethod, visitInnerClasses, visitJavaClass, visitLineNumberTable, visitLocalVariableTable, visitMethodParameters, visitParameterAnnotationEntry, visitStackMap, visitStackMapEntryMethods inherited from class edu.umd.cs.findbugs.visitclass.BetterVisitor
clone, report, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitCodeException, visitConstantClass, visitConstantDouble, visitConstantFieldref, visitConstantFloat, visitConstantInteger, visitConstantInterfaceMethodref, visitConstantLong, visitConstantMethodref, visitConstantNameAndType, visitConstantString, visitConstantUtf8, visitConstantValue, visitDeprecated, visitExceptionTable, visitInnerClass, visitLineNumber, visitLocalVariable, visitLocalVariableTypeTable, visitMethod, visitSignature, visitSourceFile, visitSynthetic, visitUnknownMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.bcel.classfile.Visitor
visitConstantDynamic, visitMethodParameter, visitModule, visitModuleExports, visitModuleMainClass, visitModuleOpens, visitModulePackages, visitModuleProvides, visitModuleRequires, visitNestHost, visitNestMembers, visitRecord, visitRecordComponent, visitStackMapType
-
Field Details
-
bugReporter
private final edu.umd.cs.findbugs.BugReporter bugReporter -
stack
private edu.umd.cs.findbugs.OpcodeStack stack -
clsName
-
clsSignature
-
localSpecialObjects
register to first allocation PC -
fieldSpecialObjects
fieldname to field sig -
sawTernary
private boolean sawTernary -
isInnerClass
private boolean isInnerClass -
savedSpecialFields
-
outerClassName
-
-
Constructor Details
-
MissingMethodsDetector
protected MissingMethodsDetector(edu.umd.cs.findbugs.BugReporter bugReporter)
-
-
Method Details
-
visitClassContext
public void visitClassContext(edu.umd.cs.findbugs.ba.ClassContext classContext) overrides the visitor to initialize and tear down the opcode stack- Specified by:
visitClassContextin interfaceedu.umd.cs.findbugs.Detector- Overrides:
visitClassContextin classedu.umd.cs.findbugs.BytecodeScanningDetector- Parameters:
classContext- the context object of the currently parsed class
-
visitField
public void visitField(org.apache.bcel.classfile.Field obj) - Specified by:
visitFieldin interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitFieldin classedu.umd.cs.findbugs.visitclass.BetterVisitor
-
visitCode
public void visitCode(org.apache.bcel.classfile.Code obj) overrides the visitor reset the stack- Specified by:
visitCodein interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitCodein classedu.umd.cs.findbugs.visitclass.PreorderVisitor- Parameters:
obj- the context object of the currently parsed code block
-
sawOpcode
public void sawOpcode(int seen) overrides the visitor to look for uses of collections where the only access to to the collection is to write to it- Overrides:
sawOpcodein classedu.umd.cs.findbugs.visitclass.DismantleBytecode- Parameters:
seen- the opcode of the currently visited instruction
-
saveSpecialFieldUse
-
getParentClassName
-
handleTernary
private void handleTernary(int seen) -
sawPutStatic
private void sawPutStatic() -
sawGetStatic
-
sawPutField
private void sawPutField() -
sawGetField
-
sawLoad
-
sawInvokeInterfaceVirtual
private void sawInvokeInterfaceVirtual() -
sawInvokeSpecial
-
sawInvokeStatic
-
sawAStore
private void sawAStore(int seen) -
nextOpIsPop
private boolean nextOpIsPop() -
clearUserValue
private void clearUserValue(edu.umd.cs.findbugs.OpcodeStack.Item item) -
getStack
protected edu.umd.cs.findbugs.OpcodeStack getStack() -
processMethodParms
protected void processMethodParms()Checks to see if any of the locals or fields that we are tracking are passed into another method. If they are, we clear out our tracking of them, because we can't easily track their progress into the method. This can be overridden to check for exceptions to this rule, for example, being logged to the console not counting. -
clearSpecialField
informs the missing method detector that a field should no longer be considered special- Parameters:
name- the name of the field
-
clearLocalObjects
private void clearLocalObjects() -
makeFieldBugInstance
protected abstract edu.umd.cs.findbugs.BugInstance makeFieldBugInstance() -
makeLocalBugInstance
protected abstract edu.umd.cs.findbugs.BugInstance makeLocalBugInstance() -
doesObjectNeedToBeWatched
-
doesStaticFactoryReturnNeedToBeWatched
-
isMethodThatShouldBeCalled
-