Package sootup.callgraph
Class ClassHierarchyAnalysisAlgorithm
java.lang.Object
sootup.callgraph.AbstractCallGraphAlgorithm
sootup.callgraph.ClassHierarchyAnalysisAlgorithm
- All Implemented Interfaces:
CallGraphAlgorithm
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.
-
Field Summary
Fields inherited from class sootup.callgraph.AbstractCallGraphAlgorithm
threadType, typeHierarchy, view -
Constructor Summary
ConstructorsConstructorDescriptionClassHierarchyAnalysisAlgorithm(@NonNull View view) The constructor of the CHA algorithm.ClassHierarchyAnalysisAlgorithm(@NonNull View view, @NonNull CallResolver callResolver) The constructor of the CHA algorithm that allows restricting which statements' calls are resolved during call graph construction.ClassHierarchyAnalysisAlgorithm(@NonNull View view, @NonNull CallResolver callResolver, @NonNull VirtualCallResolver virtualCallResolver) The constructor of the CHA algorithm that allows restricting which calls are expanded during call graph construction.ClassHierarchyAnalysisAlgorithm(@NonNull View view, @NonNull VirtualCallResolver virtualCallResolver) The constructor of the CHA algorithm that allows restricting which resolved dynamic-dispatch candidates are admitted/expanded during call graph construction. -
Method Summary
Modifier and TypeMethodDescription@NonNull CallGraphThis method initializes and starts the call graph algorithm without given entry points.@NonNull CallGraphinitialize(@NonNull List<MethodSignature> entryPoints) This method initializes and starts the call graph algorithm with given entry points.protected voidpostProcessingMethod(@NonNull MethodSignature sourceMethod, @NonNull Deque<MethodSignature> workList, @NonNull MutableCallGraph cg) This method enables optional post-processing of a method in the call graph algorithmprotected voidpreProcessingMethod(@NonNull MethodSignature sourceMethod, @NonNull Deque<MethodSignature> workList, @NonNull MutableCallGraph cg) This method enables optional pre-processing of a method in the call graph algorithmprotected @NonNull Stream<MethodSignature>resolveCall(SootMethod method, InvokableStmt invokableStmt) In the CHA algorithm, every virtual call is resolved by only using the hierarchy.Methods inherited from class sootup.callgraph.AbstractCallGraphAlgorithm
addCallToCG, addCallToCG, addCallToCG, addClass, findConcreteMethod, findDefaultMethod, findMainMethod, findMethodInHierarchy, findStaticInitializerCalls, getClinitFromEntryPoints, implicitStartRunCall, initializeCallGraph, isInterface, postProcessingStaticInitializerCalls, resolveAllCallsFromSourceMethod, resolveAllImplicitCallsFromSourceMethod, resolveAllStaticInitializerCalls, resolveConcreteDispatch
-
Constructor Details
-
ClassHierarchyAnalysisAlgorithm
The constructor of the CHA algorithm.- Parameters:
view- it contains the data of the classes and methods
-
ClassHierarchyAnalysisAlgorithm
The constructor of the CHA algorithm that allows restricting which statements' calls are resolved during call graph construction.- Parameters:
view- it contains the data of the classes and methodscallResolver- decides which statements' calls are excluded from the call graph
-
ClassHierarchyAnalysisAlgorithm
public ClassHierarchyAnalysisAlgorithm(@NonNull View view, @NonNull VirtualCallResolver virtualCallResolver) The constructor of the CHA algorithm that allows restricting which resolved dynamic-dispatch candidates are admitted/expanded during call graph construction.- Parameters:
view- it contains the data of the classes and methodsvirtualCallResolver- decides which resolved call candidates are excluded from the call graph
-
ClassHierarchyAnalysisAlgorithm
public ClassHierarchyAnalysisAlgorithm(@NonNull View view, @NonNull CallResolver callResolver, @NonNull VirtualCallResolver virtualCallResolver) The constructor of the CHA algorithm that allows restricting which calls are expanded during call graph construction.- Parameters:
view- it contains the data of the classes and methodscallResolver- decides which statements' calls are excluded from the call graphvirtualCallResolver- decides which resolved call candidates are excluded from the call graph
-
-
Method Details
-
initialize
Description copied from interface:CallGraphAlgorithmThis 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
Description copied from interface:CallGraphAlgorithmThis 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
protected @NonNull 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:
resolveCallin classAbstractCallGraphAlgorithm- 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(@NonNull MethodSignature sourceMethod, @NonNull Deque<MethodSignature> workList, @NonNull MutableCallGraph cg) Description copied from class:AbstractCallGraphAlgorithmThis method enables optional post-processing of a method in the call graph algorithm- Specified by:
postProcessingMethodin classAbstractCallGraphAlgorithm- Parameters:
sourceMethod- the processed methodworkList- the current work list that might be extendedcg- the current cg that might be extended
-
preProcessingMethod
protected void preProcessingMethod(@NonNull MethodSignature sourceMethod, @NonNull Deque<MethodSignature> workList, @NonNull MutableCallGraph cg) Description copied from class:AbstractCallGraphAlgorithmThis method enables optional pre-processing of a method in the call graph algorithm- Specified by:
preProcessingMethodin classAbstractCallGraphAlgorithm- Parameters:
sourceMethod- the processed methodworkList- the current work list that might be extendedcg- the current cg that might be extended
-