Walkinshawn JSysDG - PDF Print
Walkinshawn JSysDG - PDF Print
B relies on the execution of a predicate statement A. A data dependence
exists, if the execution of a statement B references a variable
The formal-out vertex is connected to the actual-out vertex
via a parameter-out edge (dashed line). Data dependencies
which is defined / modified in a statement A. within the method (e.g. from c=c_in to int result = c + d)
are represented by data dependence edges (dashed lines). A slicing to take individual objects into consideration [6]. A
full legend for all of the examples featured in this paper is statement vertex v which references an object is expanded
provided in appendix A. into a tree depending on the context in which v is used.
The examples (figures 3-6) are taken from the calculator
example given in appendices B and C. The following four
int added=add(a,b) sections illustrate these possible expansions:
private int add(int c, int d) added=result_out
1. v is a parameter vertex representing a statically typed2
c_in=a d_in=b
c=c_in d=d_in int result = c + d return result result_out=result object: v is expanded into a tree. Figure 3 illustrates
the callsite for computePower(e) (see node C9 in ap-
pendix), given that it can only accept objects of the
type AdvancedCalc.
Figure 1. Example of a simple method call
computePower(e)
MDG layer. For every class, there exists a class entry ver-
tex, which is connected to the method entry vertices of its
methods via class membership edges. These membership
edges can be tagged as either public, protected or package
(default) to indicate their visibility [4]. If one class inherits Figure 3. Example of single-typed parameter
from another, they are linked by a class dependence edge. object
The class entry vertex is connected to its data members via
data member edges.
Figure 2 shows the ClDG of classes SimpleCalc and 2. v is a parameter vertex representing a dynamically
AdvancedCalc (see nodes CE17 and CE46 in appendix typed3 object: v is connected to a child vertex for each
B). Inheritance is indicated by the class dependence edge possible object type and expands each child vertex into
which passes between them. Note that although Advanced- a tree containing data members belonging to that ob-
Calc inherits all of the data members and methods belong- ject. In figure 4, e can either be of types SimpleCalc
ing to SimpleCalc (apart from its constructors), it only or AdvancedCalc (see node C11 in appendix).
needs to be linked to its own specific data members and
methods. Inherited data members and methods can simply getStats(e)
SimpleCalc [4].
SimpleCalc AdvancedCalc
public class SimpleCalc implements Calculator
public power() public AdvancedCalc() public AdvancedCalc(int aIn, int bIn) public int multiply()
Figure 4. Example of polymorphic parameter
object
a b A1_out
public SimpleCalc(int a, int b) private int add(int c, int d) public int multiply(int c, int d)
Figure 5. Example of a call to a method in a
public int average()
vertex )
within a method m and GREF(m) is the set of non-local variables which 6 An example of this would be i.compareTo(new Integer(5)); where i
If the JSysDG is to be sliced, it needs an additional 4.3. Software Inspections / Program Understanding
edge called the summary edge. These represent the tran-
sitive flow of dependence across a callsite caused by both Dunsmore et al. state that delocalised software arti-
control and data dependencies. Such an edge connects an facts hamper object oriented code inspections [15]. Soft-
actual-in vertex to an actual-out vertex if the value asso- ware artifacts become delocalised because object-oriented
ciated with the actual-in vertex may affect the value as- paradigm features such as inheritance, polymorphism and
sociated with the actual-out vertex. Figure 10 shows the dynamic binding can cause code which is responsible for
same callsite example as figure 1, but adds transitive depen- the execution of a single task to be dispersed throughout
dencies from c_in=a to added=result_out and d_in=b to the program. These dispersed artifacts are all connected
added=result_out. via some form of dependence (or chain of dependencies),
which can be traced on the JSysDG. Slicing could be used to
statically determine possible paths of execution in the pro-
gram, providing the inspector with a reading strategy for the
int added=add(a,b)
inspection.
Harman et al. propose a framework for combining slic-
private int add(int c, int d) c_in=a d_in=b added=result_out
ing and concept assignment [16], to facilitate program un-
c=c_in d=d_in int result = c + d return result result_out=result derstanding. Further research is required if this approach
is to be made practical for object-oriented systems. The
JSysDG provides a useful basis for investigating the feasi-
bility of extracting Executable Concept Slices (ECSs) for
Figure 9. Example of method call with transi- object-oriented programs.
tive edges between actual-in and actual-out
vertices 4.4. Practical Issues
[1] K. Ottenstein and L. Ottenstein, “The program depen- [13] M. Weiser, “Program slicing,” in Proc. 5th Int. Confer-
dence graph in a software development environment,” ence on Software Engineering, (New York), pp. 439–
in Proceedings of the ACM SIGSOFT/SIGPLAN Soft- 449, IEEE, 1981.
ware Engineering Symposium on Practical Software [14] J. Bieman and L. Ott, “Measuring functional cohe-
Development Environments, pp. 177–184, 1984. sion,” IEEE Transactions on Software Engineering,
[2] S. Horwitz, T. Reps, and D. Binkley, “Interprocedural vol. 20, pp. 644–658, August 1994.
slicing using dependence graphs,” ACM Transactions
[15] A. Dunsmore, M. Roper, and M. Wood, “Object-
on Programming Languages and Systems, vol. 12,
oriented inspection in the face of delocalisation,” in
pp. 26–60, January 1990.
Proceedings of the 22nd International Conference on
[3] L. Larsen and M. Harrold, “Slicing object oriented Software Engineering, (Limerick), 2000.
software,” in 18th International Conference on Soft-
ware Engineering, pp. 495–505, March 1996. [16] M. Harman, N. Gold, R. Hierons, and D. Binkley,
“Code extraction algorithms which unify slicing and
[4] G. Kovacs, F. Magyar, and T. Gyimothy, “Static slic- concept assignment,” in 9th IEEE Conference on Re-
ing of Java programs,” Tech. Rep. TR-96-108, Re- verse Engineering (WCRE ’02), (Richmond, Virginia,
search Group on Artificial Intelligence, Hungarian USA), 2002.
Academy of Sciences, Joesf Attila University, 1996.
[17] S. Sinha, M. Harrold, and G. Rothermel, “System-
[5] J. Zhao, “Applying program dependence analysis to dependence-graph-based slicing of programs with ar-
Java software,” in Proc. Workshop on Software En- bitrary interprocedural control flow,” in Proceedings
gineering and Database Systems, (Taiwan), pp. 162– of the 21st International Conference on Software En-
169, December 1998. gineering, May 1999.
[6] D. Liang and M. Harrold, “Slicing objects using sys- [18] J. Zhao, “Multithreaded dependence graphs for con-
tem dependence graphs,” International Conference on current Java programs,” in Proceedings of the Seventh
Software Maintenance, pp. 358–367, November 1998. IEEE International Workshop on Program Compre-
[7] M. Shaw, Pattern Languages of Program Design, hension (IWPC ’99), pp. 126–133, May 1999.
ch. 24. Addison Wesley, 1996.
[8] C. Chambers, I. Pechtchanski, V. Sarkar, M. Serrano,
and H. Srinivasan, “Dependence analysis for Java,” in
Workshop on Compilers for Parallel Computing, (La
Jolla, LA), August 1999.
[9] P. Tonella, G. Antoniol, R. Fuitem, and E. Merlo,
“Flow insensitive C++ pointers and polymorphism
analysis and its application to slicing,” 19th Interna-
tional Conference on Software Engineering, pp. 433–
443, May 1997.
Appendix A: Legend
class entry vertex / interface entry vertex
method entry vertex / statement vertex / formal or actual parameter in/out vertex
control dependence
transitive dependence
E2 public static void main(String args[]){ S18 int a,b; E44 int average();
C7 e = new SimpleCalc(a, b); E22 public SimpleCalc(int aIn, int bIn){ E47 public AdvancedCalc(){
{ } }
C8 e = new AdvancedCalc(); E25 public int average(){ E50 public AdvancedCalc(int aIn, int bIn){
S12 System.out.println(e.multiply(6,20)); E29 private int add(int c, int d){ S54 int result = c*d;
E15 public static void computePower(AdvancedCalc e){ S33 int result = c/2; S58 return result;
} } }
S37 d=d+d;
S38 return d;
S40 return a;
S42 return b;
}
Appendix C: Entire JSysDG for Example Code
This page is best viewed in colour (A colour image can be downloaded from:
http://www.cs.strath.ac.uk/~nw/documents.html).
CE1
F1_in E2
S3 S4
C9 S10
C5 C6 C7 C8 S10(a) C11 S12
a b a b a b
SimpleCalc AdvancedCalc e
e SimpleCalc.multiply
a b a b AdvancedCalc.multiply
E15
S16
SimpleCalc AdvancedCalc 6 20 6 20
AdvancedCalc C16(a)
a b a b
a b AdvancedCalc.multiply
a b A14_out
E13
e
IE43 S14
SimpleCalc AdvancedCalc
C14(a) C14(b)
E44 E45
CE17
S18(a)
S18(b)
E22
E19
S28 F13_out
S20 S21
A8_in A9_in A9_out
C26 C27
E39
E29 A10_in A11_in A11_out A12_in A12_out
E32
E35
S37
CE46
F4_in F5_in F4_out F5_out F8_in F9_in F9_out F16_in F17_in F17_out
F6_in F7_in S51 C52 F4_out F5_out
F4_in F5_in
S48 S49
Vertices marked by the first phase of the slice are shown in blue (darker shade) and those marked by the second phase are
shown in pink (lighter shade). A backwards-slice is demonstrated, taken from vertex S25 (return divided).