Class LabeledGraphBasedCallGraph<L>

java.lang.Object
sootup.callgraph.GraphBasedCallGraph
sootup.callgraph.LabeledGraphBasedCallGraph<L>
Type Parameters:
L - the type of the labels attached to the calls
All Implemented Interfaces:
CallGraph, LabeledCallGraph<L>, MutableCallGraph, MutableLabeledCallGraph<L>

public class LabeledGraphBasedCallGraph<L> extends GraphBasedCallGraph implements MutableLabeledCallGraph<L>
This class implements a mutable call graph as a graph whose calls can carry labels of type L. The labels of a call keep their insertion order.

Call graph algorithms create a plain GraphBasedCallGraph. Use of(CallGraph) to label their result, or override AbstractCallGraphAlgorithm.initializeCallGraph(List, List) to return a labeled call graph that is filled during the construction.

GraphBasedCallGraph.diff(CallGraph) compares the calls only and ignores labels.

  • Constructor Details

    • LabeledGraphBasedCallGraph

      public LabeledGraphBasedCallGraph(@NonNull List<MethodSignature> entryMethods)
      The constructor of the labeled graph based call graph. it initializes an empty call graph.
      Parameters:
      entryMethods - the entry methods of the call graph
    • LabeledGraphBasedCallGraph

      protected LabeledGraphBasedCallGraph(@NonNull GraphBasedCallGraph callGraph, @NonNull com.google.common.collect.SetMultimap<CallGraph.Call,L> labels)
  • Method Details

    • of

      public static <L> @NonNull LabeledGraphBasedCallGraph<L> of(@NonNull CallGraph callGraph)
      Creates a labeled copy of the given call graph. The given call graph is not modified. If it is a LabeledCallGraph its labels are copied as well; they must be of type L.
      Type Parameters:
      L - the type of the labels attached to the calls
      Parameters:
      callGraph - the call graph whose methods and calls are copied
      Returns:
      a labeled call graph containing the methods and calls of the given call graph
    • addLabel

      public void addLabel(@NonNull CallGraph.Call call, @NonNull L label)
      Description copied from interface: MutableLabeledCallGraph
      This method attaches a label to a call in the call graph. A call can carry several labels. A label that is already attached to the call is not added a second time.
      Specified by:
      addLabel in interface MutableLabeledCallGraph<L>
      Parameters:
      call - the call the label is attached to. It must be contained in the call graph.
      label - the label that will be attached to the call
    • removeLabel

      public boolean removeLabel(@NonNull CallGraph.Call call, @NonNull L label)
      Description copied from interface: MutableLabeledCallGraph
      This method removes a label from a call in the call graph.
      Specified by:
      removeLabel in interface MutableLabeledCallGraph<L>
      Parameters:
      call - the call the label is removed from
      label - the label that will be removed
      Returns:
      true if the label was attached to the call, otherwise false
    • getLabels

      public @NonNull Set<L> getLabels(@NonNull CallGraph.Call call)
      Description copied from interface: LabeledCallGraph
      This method returns all labels attached to a call in the call graph.
      Specified by:
      getLabels in interface LabeledCallGraph<L>
      Parameters:
      call - the requested call in the call graph
      Returns:
      an unmodifiable set of the labels of the call. It is empty if the call has no labels or is not contained in the call graph.
    • copy

      public @NonNull LabeledGraphBasedCallGraph<L> copy()
      Description copied from interface: CallGraph
      This method copies a call graph.
      Specified by:
      copy in interface CallGraph
      Specified by:
      copy in interface LabeledCallGraph<L>
      Overrides:
      copy in class GraphBasedCallGraph
      Returns:
      it returns a copied call graph.
    • printCallingMethods

      protected String printCallingMethods(CallGraph.Call call)
      Description copied from class: GraphBasedCallGraph
      This returns the string that is used in the toString Method to define the methods that call a specific method
      Overrides:
      printCallingMethods in class GraphBasedCallGraph
      Parameters:
      call - The data of the call
      Returns:
      The returned String will be used in the toString method to define the methods that call a specific method
    • printCalledMethods

      protected String printCalledMethods(CallGraph.Call call)
      Description copied from class: GraphBasedCallGraph
      This returns the string that is used in the toString Method to define the called methods
      Overrides:
      printCalledMethods in class GraphBasedCallGraph
      Parameters:
      call - The data of the call
      Returns:
      The returned String will be used in the toString method to define the called methods
    • printLabels

      protected String printLabels(CallGraph.Call call)
      This returns the string that is used in the toString Method to print the labels of a call
      Parameters:
      call - The data of the call
      Returns:
      the labels of the call prefixed by a space, or an empty string if the call has no labels