Class ClassHierarchyAnalysisAlgorithm

java.lang.Object
sootup.callgraph.AbstractCallGraphAlgorithm
sootup.callgraph.ClassHierarchyAnalysisAlgorithm
All Implemented Interfaces:
CallGraphAlgorithm

public class ClassHierarchyAnalysisAlgorithm extends AbstractCallGraphAlgorithm
This class implements the Class Hierarchy Analysis call graph algorithm. In this algorithm, every virtual call is resolved to the all implemented overwritten methods of subclasses in the entire class path.
  • Constructor Details

    • ClassHierarchyAnalysisAlgorithm

      public ClassHierarchyAnalysisAlgorithm(@Nonnull View view)
      The constructor of the CHA algorithm.
      Parameters:
      view - it contains the data of the classes and methods
  • Method Details

    • initialize

      @Nonnull public CallGraph initialize()
      Description copied from interface: CallGraphAlgorithm
      This method initializes and starts the call graph algorithm without given entry points. Before the algorithm is started, all main methods are searched and set as entry points.
      Returns:
      a generated call graph with every main class as starting point.
    • initialize

      @Nonnull public CallGraph initialize(@Nonnull List<MethodSignature> entryPoints)
      Description copied from interface: CallGraphAlgorithm
      This method initializes and starts the call graph algorithm with given entry points. The entry points define the start methods in the call graph algorithm.
      Parameters:
      entryPoints - a list of entry points for the call graph algorithm. The algorithm starts at these methods and inspects all reachable methods.
      Returns:
      a generated call graph with every entry point as starting point.
    • resolveCall

      @Nonnull protected Stream<MethodSignature> resolveCall(SootMethod method, InvokableStmt invokableStmt)
      In the CHA algorithm, every virtual call is resolved by only using the hierarchy. Every subclass of the class is considered as target if it contains an implementation of the methods called in the invoke expression.
      Specified by:
      resolveCall in class AbstractCallGraphAlgorithm
      Parameters:
      method - the method object that contains the given invoke expression in the body.
      invokableStmt - it contains the call which is resolved.
      Returns:
      a stream containing all reachable method signatures after applying the CHA call graph algorithm
    • postProcessingMethod

      protected void postProcessingMethod(View view, MethodSignature sourceMethod, @Nonnull Deque<MethodSignature> workList, @Nonnull MutableCallGraph cg)
      Description copied from class: AbstractCallGraphAlgorithm
      This method enables optional post-processing of a method in the call graph algorithm
      Specified by:
      postProcessingMethod in class AbstractCallGraphAlgorithm
      Parameters:
      view - it contains classes and the type hierarchy.
      sourceMethod - the processed method
      workList - the current work list that might be extended
      cg - the current cg that might be extended
    • preProcessingMethod

      protected void preProcessingMethod(View view, MethodSignature sourceMethod, @Nonnull Deque<MethodSignature> workList, @Nonnull MutableCallGraph cg)
      Description copied from class: AbstractCallGraphAlgorithm
      This method enables optional pre-processing of a method in the call graph algorithm
      Specified by:
      preProcessingMethod in class AbstractCallGraphAlgorithm
      Parameters:
      view - view
      sourceMethod - the processed method
      workList - the current work list that might be extended
      cg - the current cg that might be extended