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
    Modifier and Type
    Class
    Description
    private static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final edu.umd.cs.findbugs.BugReporter
     
    private String
     
    private String
     
    private Map<String,String>
    fieldname to field sig
    private boolean
     
    register to first allocation PC
    private String
     
    private Map<String,Set<FQField>>
     
    private boolean
     
    private edu.umd.cs.findbugs.OpcodeStack
     

    Fields inherited from class edu.umd.cs.findbugs.visitclass.DismantleBytecode

    codeBytes, lineNumberTable, M_BR, M_CP, M_INT, M_PAD, M_R, M_UINT

    Fields inherited from interface edu.umd.cs.findbugs.Priorities

    EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    MissingMethodsDetector(edu.umd.cs.findbugs.BugReporter bugReporter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
     
    protected void
    informs the missing method detector that a field should no longer be considered special
    private void
    clearUserValue(edu.umd.cs.findbugs.OpcodeStack.Item item)
     
    protected abstract boolean
     
    protected abstract boolean
    doesStaticFactoryReturnNeedToBeWatched(String clsName, String methodName, String signature)
     
    protected String
     
    protected edu.umd.cs.findbugs.OpcodeStack
     
    private void
    handleTernary(int seen)
     
    protected abstract boolean
     
    protected abstract edu.umd.cs.findbugs.BugInstance
     
    protected abstract edu.umd.cs.findbugs.BugInstance
     
    private boolean
     
    protected void
    Checks to see if any of the locals or fields that we are tracking are passed into another method.
    protected void
    saveSpecialFieldUse(String owningClassName, String fieldName, String signature)
     
    private void
    sawAStore(int seen)
     
    private Object
    sawGetField(Object userObject)
     
    private Object
    sawGetStatic(Object userObject)
     
    private void
     
    private Object
     
    private Object
    sawInvokeStatic(Object userObject)
     
    private Object
    sawLoad(int seen, Object userObject)
     
    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
    private void
     
    private void
     
    void
    visitClassContext(edu.umd.cs.findbugs.ba.ClassContext classContext)
    overrides the visitor to initialize and tear down the opcode stack
    void
    visitCode(org.apache.bcel.classfile.Code obj)
    overrides the visitor reset the stack
    void
    visitField(org.apache.bcel.classfile.Field obj)
     

    Methods inherited from class edu.umd.cs.findbugs.BytecodeScanningDetector

    getClassContext, report, shouldVisitCode

    Methods 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, visit

    Methods inherited from class edu.umd.cs.findbugs.visitclass.AnnotationVisitor

    getAnnotationParameterAsEnum, getAnnotationParameterAsString, getAnnotationParameterAsStringArray, visitAnnotation, visitAnnotation, visitParameterAnnotation, visitParameterAnnotation, visitSyntheticParameterAnnotation

    Methods 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, visitStackMapEntry

    Methods 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, visitUnknown

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods 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

      private String clsName
    • clsSignature

      private String clsSignature
    • localSpecialObjects

      private Map<Integer,MissingMethodsDetector.LocalUse> localSpecialObjects
      register to first allocation PC
    • fieldSpecialObjects

      private Map<String,String> fieldSpecialObjects
      fieldname to field sig
    • sawTernary

      private boolean sawTernary
    • isInnerClass

      private boolean isInnerClass
    • savedSpecialFields

      private Map<String,Set<FQField>> savedSpecialFields
    • outerClassName

      private String 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:
      visitClassContext in interface edu.umd.cs.findbugs.Detector
      Overrides:
      visitClassContext in class edu.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:
      visitField in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitField in class edu.umd.cs.findbugs.visitclass.BetterVisitor
    • visitCode

      public void visitCode(org.apache.bcel.classfile.Code obj)
      overrides the visitor reset the stack
      Specified by:
      visitCode in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitCode in class edu.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:
      sawOpcode in class edu.umd.cs.findbugs.visitclass.DismantleBytecode
      Parameters:
      seen - the opcode of the currently visited instruction
    • saveSpecialFieldUse

      protected void saveSpecialFieldUse(String owningClassName, String fieldName, String signature)
    • getParentClassName

      protected String getParentClassName()
    • handleTernary

      private void handleTernary(int seen)
    • sawPutStatic

      private void sawPutStatic()
    • sawGetStatic

      private Object sawGetStatic(Object userObject)
    • sawPutField

      private void sawPutField()
    • sawGetField

      private Object sawGetField(Object userObject)
    • sawLoad

      private Object sawLoad(int seen, Object userObject)
    • sawInvokeInterfaceVirtual

      private void sawInvokeInterfaceVirtual()
    • sawInvokeSpecial

      private Object sawInvokeSpecial(Object userObject)
    • sawInvokeStatic

      private Object sawInvokeStatic(Object userObject)
    • 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

      protected void clearSpecialField(String name)
      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

      protected abstract boolean doesObjectNeedToBeWatched(@DottedClassName String type)
    • doesStaticFactoryReturnNeedToBeWatched

      protected abstract boolean doesStaticFactoryReturnNeedToBeWatched(String clsName, String methodName, String signature)
    • isMethodThatShouldBeCalled

      protected abstract boolean isMethodThatShouldBeCalled(String methodName)