Class Spark
Exposes the call graph (CHA up-front, supplied by the client, or built on-the-fly when
SparkOptions#isOnFlyCallGraph() is set) and a PointsToAnalysis over the resulting PAG.
Lower-level components such as the solver are package-private; clients should not bypass this
facade.
Spark spark = Spark.builder()
.view(view)
.entryPoints(List.of(mainSig))
.sparkOptions(SparkOptions.builder().onFlyCallGraph(true).build())
.build();
PointsToAnalysis pta = spark.getPointsToAnalysis();
CallGraph cg = spark.getCallGraph();
To reuse a call graph the client already computed instead of having SPARK run CHA, pass it via
callGraph(...). This is ignored (with a warning logged) when onFlyCallGraph is
on, since OTF mode grows its own call graph incrementally from the entry points instead of
consuming one.
Spark has no <clinit>-handling knob of its own; this is also the way to control it in
the non-OTF path. Pre-build the graph with ClassHierarchyAnalysisAlgorithm's
seedEntryPointClinits/sootup.callgraph.scope.VirtualCallResolver constructor and pass it
via callGraph(...) instead of letting Spark run CHA with its defaults.
reflectionModel(...) (default ReflectionModel.none()) makes reflective calls
explicit in every body Spark reads. dynamicInvokeResolver(...) (default
DynamicInvokeResolver.bootstrapMethodHandles()) decides invokedynamic targets; values captured
by a lambda flow into its body. When passing a pre-built callGraph, build it with the
same model and resolver instances, else reflective/invokedynamic edges and PAG disagree.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the call graph: the one passed to the builder, one built via class-hierarchy analysis at construction time, or one grown on-the-fly duringsolve()whenSparkOptions#isOnFlyCallGraph()is set.getPag()Returns the underlying pointer assignment graph — intended for inspection and debugging.Returns a points-to analysis over the solved PAG.voidsolve()Builds the pointer assignment graph and (in OTF mode) the call graph.
-
Method Details
-
solve
public void solve()Builds the pointer assignment graph and (in OTF mode) the call graph. Invoked automatically by the accessors; calling it explicitly is optional and idempotent. -
getCallGraph
Returns the call graph: the one passed to the builder, one built via class-hierarchy analysis at construction time, or one grown on-the-fly duringsolve()whenSparkOptions#isOnFlyCallGraph()is set. -
getPointsToAnalysis
Returns a points-to analysis over the solved PAG. The result is cached. -
getPag
Returns the underlying pointer assignment graph — intended for inspection and debugging. -
getSparkOptions
-