Class FindNoSideEffectMethods

All Implemented Interfaces:
Detector, FirstPassDetector, NonReportingDetector, Priorities, org.apache.bcel.classfile.Visitor

public class FindNoSideEffectMethods extends OpcodeStackDetector implements NonReportingDetector
  • Field Details

  • Constructor Details

    • FindNoSideEffectMethods

      public FindNoSideEffectMethods(BugReporter bugReporter)
  • Method Details

    • visit

      public void visit(org.apache.bcel.classfile.JavaClass obj)
      Overrides:
      visit in class BetterVisitor
    • visit

      public void visit(org.apache.bcel.classfile.Method method)
      Overrides:
      visit in class BetterVisitor
    • visit

      public void visit(org.apache.bcel.classfile.Field obj)
      Overrides:
      visit in class BetterVisitor
    • visitAfter

      public void visitAfter(org.apache.bcel.classfile.JavaClass obj)
      Overrides:
      visitAfter in class PreorderVisitor
    • superClinitCall

      private void superClinitCall()
    • handleStatus

      private void handleStatus()
    • visit

      public void visit(org.apache.bcel.classfile.Code obj)
      Overrides:
      visit in class DismantleBytecode
    • sawOpcode

      public void sawOpcode(int seen)
      Description copied from class: OpcodeStackDetector

      By default, this method will not be called when stack is TOP. To change this behavior, override #beforeOpcode(int) and change to return true even if stack is TOP.

      see Using FindBugs for Research to learn lattice and what TOP means.

      Specified by:
      sawOpcode in class OpcodeStackDetector
      See Also:
    • getMethodCall

      private FindNoSideEffectMethods.MethodCall getMethodCall(MethodDescriptor methodDescriptorOperand)
    • sawCall

      private void sawCall(FindNoSideEffectMethods.MethodCall methodCall, boolean finalPass)
    • sawNoSideEffectCall

      private void sawNoSideEffectCall(MethodDescriptor methodDescriptor)
      Parameters:
      methodDescriptor -
    • sawUnsureCall

      private void sawUnsureCall(FindNoSideEffectMethods.MethodCall methodCall)
    • isNew

      private static boolean isNew(OpcodeStack.Item item)
      Parameters:
      item - stack item to check
      Returns:
      true if this stack item is known to be newly created
    • changesOnlyNewObjects

      private boolean changesOnlyNewObjects(MethodDescriptor methodDescriptor)
    • changedArg

      private static int changedArg(MethodDescriptor m)
      Parameters:
      m - method to check
      Returns:
      array of argument numbers (0-based) which this method writes into or null if we don't know anything about this method
    • hasNoSideEffect

      private static boolean hasNoSideEffect(MethodDescriptor m)
      Parameters:
      m - method to check
      Returns:
      true if given method is known to have no side effects
    • hasNoSideEffectUnknown

      private static boolean hasNoSideEffectUnknown(MethodDescriptor m)
      Parameters:
      m - method to check
      Returns:
      true if we may assume that given unseen method has no side effect
    • isObjectOnlyMethod

      private static boolean isObjectOnlyMethod(MethodDescriptor m)
      Parameters:
      m - method to check
      Returns:
      true if given method is known to change its object only
    • isObjectOnlyClass

      private static boolean isObjectOnlyClass(String className)
      Parameters:
      className - class to check
      Returns:
      true if all methods of this class are known to be object-only or no-side-effect
    • report

      public void report()
      Description copied from interface: Detector
      This method is called after all classes to be visited. It should be used by any detectors which accumulate information over all visited classes to generate results.
      Specified by:
      report in interface Detector
      Overrides:
      report in class BytecodeScanningDetector
    • hasOtherImplementations

      private static boolean hasOtherImplementations(XMethod xMethod)
      Parameters:
      xMethod -
      Returns:
      true if this has other implementations
    • computeFinalStatus

      private void computeFinalStatus()