Databases Reference
In-Depth Information
11.6.7 External Dependencies
The dependency slicing algorithm described so far works well so long as source
code is available for all the sliced declarations. It's only with access to this source
code that we are able to reconstruct partial type declarations to match the entities in
the slice.
Dependencies on external projects are usually realized through the inclusion
of jar files, which often do not contain source code. Even if the source code is
available for these external dependencies, extending the slice into them may not
necessarily be advantageous, as it would create incompatibilities with the pack-
aged versions of those projects. This would be especially problematic with the
Java Standard Library, as creating sliced versions of java.lang.Object or
java.io.PrintStream could be exceedingly confusing.
All slicing behavior is therefore limited to the project containing the seed decla-
rations, with all external references fully preserved, allowing the original jar files to
be included. In order to support this logic, a few changes needed to be made to the
algorithms previously described.
In the basic algorithm, it is no longer necessary to perform a slicing analysis for
external references. Any declaration that is added to the work-list but is external to
the project just gets included in its entirety. This has cascading effects on the slicing
of the type hierarchy. Any type included in the slice but external to the project must
include all of its supertypes. Similarly, all methods required by an external abstract
supertype must be included, not just those referenced in the slice.
This alteration introduces a potential source of error with respect to the type
hierarchy. Consider the following class declarations:
class A
extends
ArrayList
{
public void sort () {
Collections . sort ( this );
}
}
This class extends java.util.ArrayList , but never references it outside of the
extends clause. Yet the call to java.util.Collections.sort(List<T>) re-
quires that A extend ArrayList (because ArrayList implements List ). If Col-
lection's sort method is not analyzed, then java.util.List does not get added to
the slice, and the necessary type relationship is not preserved. In order to handle
this, we must examine external method and constructor calls and add their formal
parameter types to the slice. This ensures that if an external method expects a certain
type, that type is included in the slice.
11.6.8 Complete Algorithm
The full algorithm is shown in Algorithm 3 . The method CheckHierarchy on line
20 was described in Algorithm 2 . CheckDefaultConstructors on line 26 adds any
default constructors, and determines if other constructors must be added to stop the
compiler from synthesizing a default constructor.
Search WWH ::




Custom Search