Databases Reference
In-Depth Information
DataflowExample {
PrintWriter debugLog;
readFile(File f) Exception {
FileInputStream is = FileInputStream(f);
[]b= [1000];
(is.read(b) != -1) {
// use b
}
is.close();
debugLog.write("Readingfile:Done.");
}
}
FIGURE 4.5: Several calls to objects from java.io. Dataflow analysis ex-
tracts the highlighted calls, which are relevant for showing a typical use of
FileInputStream.
Figure 4.3(a) for package java.util removes the calls to m(), and hence, leaves
only calls relevant for using an iterator.
The package to focus on can be given as a parameter to our analysis.
Alternatively, we provide an automatic mode, where relevant packages are de-
termined for each collaboration. For that purpose, each package with at least
two calls related to it is considered. Package-based filtering transforms one
collaboration into zero, one, or more collaborations. For example, a method
may use an iterator (related to java.util ) and write to an output stream (re-
lated to java.io). Such a collaboration is transformed into two collaborations:
one with calls related to java.util and one with calls related to java.io.
4.2.3.4
Dataflow Filtering
Larger methods that call many other methods can result in large collabo-
rations. Sometimes, two or more API usages are interleaved within a method.
For instance, Figure 4.5 shows a method that uses a FileInputStream and a
PrintWriter. To obtain a protocol of using FileInputStream, the call to the
PrintWriter is unnecessary, but since both belong to java.io package-based
filtering cannot split the collaboration accordingly.
Our analysis tries to separate interleaved method call sequences based
on dataflow relations between method calls. Since our approach is dynamic,
precise and unambiguous information about object identities and the dataflow
between objects is available. Based on this knowledge, the analysis computes
dataflow-related subsequences of calls:
First, the analysis computes the set of objects that are related to each
call, that is, its callee, parameters, and return value. Based on these sets
 
Search WWH ::




Custom Search