You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorial/FixedPointAnalyses.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -386,7 +386,7 @@ <h2 id="running-the-analysis">Running the Analysis</h2>
386
386
[...]
387
387
}
388
388
</code></pre>
389
-
<p>We use the <ahref="/library/api/SNAPSHOT/org/opalj/br/fpcf/FPCFAnalysesManagerKey$.html"><code>FPCFAnalysisManagerKey</code></a> to get an <ahref="/library/api/SNAPSHOT/org/opalj/br/fpcf/FPCFAnalysesManager.html"><code>FPCFAnalysisManager</code></a> that will run our analyses.<br/>
389
+
<p>We use the <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/FPCFAnalysesManagerKey$.html"><code>FPCFAnalysesManagerKey</code></a> to get an <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/FPCFAnalysesManager.html"><code>FPCFAnalysesManager</code></a> that will run our analyses.<br/>
390
390
We just pass all analyses that we want to execute to the <code>runAll</code> method.<br/>
391
391
Note that we assume that a <code>LazyFieldImmutabilityAnalysis</code> has been implemented as well.<br/>
392
392
As long as that doesn't exist, you can remove that line and OPAL will use the fallback value of the <code>FieldImmutability</code> lattice whenever a field immutability is queried.</p>
<p>First, <code>requiredProjectInformation</code> gives the <ahref="/library/api/SNAPSHOT/org/opalj/br/analyses/ProjectInformationKey.html"><code>ProjectInformationKey</code>s</a> that your analysis uses.<br/>
96
+
<p>First, <code>requiredProjectInformation</code> gives the <ahref="/library/api/SNAPSHOT/org/opalj/si/ProjectInformationKey.html"><code>ProjectInformationKey</code>s</a> that your analysis uses.<br/>
97
97
ProjectInformationKeys provide aggregated information about a project, such as a call graph or the set of methods that access each field.<br/>
98
-
Here, we specified the <ahref="/library/api/SNAPSHOT/org/opalj/br/analyses/FieldAccessInformationKey$.html"><code>FieldAccessInformationKey</code></a> that you can use with <ahref="/library/api/SNAPSHOT/org/opalj/br/analyses/Project.html#get[T%3C:AnyRef](pik:org.opalj.br.analyses.ProjectInformationKey[T,_]):T"><code>Project.get()</code></a> to get <ahref="/library/api/SNAPSHOT/org/opalj/br/analyses/FieldAccessInformation.html"><code>FieldAccessInformation</code></a>, i.e., information about where each field is read or written.</p>
98
+
Here, we specified the <ahref="/library/api/SNAPSHOT/org/opalj/br/analyses/FieldAccessInformationKey$.html"><code>FieldAccessInformationKey</code></a> that you can use with <ahref="/library/api/SNAPSHOT/org/opalj/si/Project.html#get[T%3C:AnyRef](pik:org.opalj.si.ProjectInformationKey[T,_]):T"><code>Project.get()</code></a> to get <ahref="/library/api/SNAPSHOT/org/opalj/br/analyses/FieldAccessInformation.html"><code>FieldAccessInformation</code></a>, i.e., information about where each field is read or written.</p>
99
99
<p>Second, <code>uses</code> gives the results of fixed-point analyses that your analysis requires.<br/>
100
100
Here, our analysis uses upper bounds for both <code>FieldImmutability</code> and <code>ClassImmutability</code>.<br/>
101
101
You can specify other bounds using other methods from <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/PropertyBounds$.html"><code>PropertyBounds</code></a>.<br/>
102
102
Remember to always include the type(s) of results produced by your own analysis as well if you use them!</p>
103
103
<p>In general, every scheduler also has to provide information on what type(s) of results your analysis produces, but this is specified differently for different schedulers.
104
104
Let's take a look at the individual scheduler types now.</p>
105
105
<h2id="eager-scheduling">Eager Scheduling</h2>
106
-
<p>The <ahref="/library/api/SNAPSHOT/org/opalj/br/fpcf/FPCFEagerAnalysisScheduler.html"><code>FPCFEagerAnalysisScheduler</code></a> is for simple analyses that compute some properties for a number of entities that you know in advance.<br/>
106
+
<p>The <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/FPCFEagerAnalysisScheduler.html"><code>FPCFEagerAnalysisScheduler</code></a> is for simple analyses that compute some properties for a number of entities that you know in advance.<br/>
107
107
For example, you could compute the immutability for all fields of all classes in your analyzed program like this:</p>
Note that you can specify more than just one type of result if your analysis computes several properties at once.
124
124
<ahref="/tutorial/CollaborativeAnalyses.html">Collaborative Analyses</a> use the <code>derivesCollaboratively</code> instead and you can combine both if necessary.</p>
125
125
<p>The eager scheduler's entry point is the <code>start</code> method.<br/>
126
-
You are given the <ahref="/library/api/SNAPSHOT/org/opalj/br/analyses/Project.html"><code>Project</code></a>, i.e., your analyzed program and the <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/PropertyStore.html"><code>PropertyStore</code></a> that will execute your analyses.<br/>
126
+
You are given the <ahref="/library/api/SNAPSHOT/org/opalj/si/Project.html"><code>Project</code></a>, i.e., your analyzed program and the <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/PropertyStore.html"><code>PropertyStore</code></a> that will execute your analyses.<br/>
127
127
You can also get some initialization data if you need it, see <ahref="#advanced-scheduling">Advanced Scheduling</a> below for more information.</p>
128
128
<p>After creating your analysis, you use <code>scheduleEagerComputation</code> to schedule it.<br/>
129
129
The first argument gives the entities for which you want to compute properties. Your analysis function will be called once for each entity.<br/>
130
130
The second argument is the analysis function. It must take a single argument of the type of your entities and produce a <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/PropertyComputationResult.html"><code>PropertyComputationResult</code></a>.
131
131
In the end, you return your analysis object.</p>
132
132
<h2id="lazy-scheduling">Lazy Scheduling</h2>
133
-
<p>The <ahref="/library/api/SNAPSHOT/org/opalj/br/fpcf/FPCFEagerAnalysisScheduler.html"><code>FPCFLazyAnalysisScheduler</code></a> lets you compute properties only for entities that need them, i.e., properties that are queried by other analyses<suptitle="You can also manually tell the PropertyStore to compute the property for some entity using the force method.">[note]</sup>.
133
+
<p>The <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/FPCFEagerAnalysisScheduler.html"><code>FPCFLazyAnalysisScheduler</code></a> lets you compute properties only for entities that need them, i.e., properties that are queried by other analyses<suptitle="You can also manually tell the PropertyStore to compute the property for some entity using the force method.">[note]</sup>.
134
134
Let's again implement a scheduler for a field immutability analysis:</p>
It also takes an analysis function, but this time, it must take a single argument that could be <em>any</em> type of entity. You can throw an exception if it doesn't match your expected type of entity, though.
153
153
As before, the analysis function must return a PropertyComputationResult.</p>
154
154
<h2id="transformers">Transformers</h2>
155
-
<p>The <ahref="/library/api/SNAPSHOT/org/opalj/br/fpcf/FPCFTransformerScheduler.html"><code>FPCFTransformerScheduler</code></a> is a special kind of lazy scheduler.<br/>
155
+
<p>The <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/FPCFTransformerScheduler.html"><code>FPCFTransformerScheduler</code></a> is a special kind of lazy scheduler.<br/>
156
156
As with a lazy scheduler, properties are only computed for entities that are queried.
157
157
However, in contrast to the lazy scheduler, the analysis function is only called once some other property for the same entity has a final result.</p>
158
158
<p>As an example, see the following scheduler:</p>
Note that it is not necessary to explicitly query for this required property: when the property computed by the transformer is queried, that automatically triggers the computation of its required property as well.<br/>
179
179
The analysis function here takes two arguments: the entity (as with lazy schedulers, this could be on any type) and the required property (a <code>BaseAIResult</code> here).</p>
<p>The <ahref="/library/api/SNAPSHOT/org/opalj/br/fpcf/FPCFTriggeredAnalysisScheduler.html"><code>FPCFTriggeredAnalysisScheduler</code></a> lets you start a computation for an entity only once you know that this entity does have some other property.<br/>
181
+
<p>The <ahref="/library/api/SNAPSHOT/org/opalj/fpcf/FPCFTriggeredAnalysisScheduler.html"><code>FPCFTriggeredAnalysisScheduler</code></a> lets you start a computation for an entity only once you know that this entity does have some other property.<br/>
182
182
Different to a transformer, that other property does not have to have a final result yet, though.<br/>
183
183
Let's see an example of how to use this for a call graph module:</p>
0 commit comments