0% found this document useful (0 votes)
46 views8 pages

How To Draw Diagram - Noda

This document proposes a sequence diagram slicing method that extends the authors' previous work. The proposed method allows for more precise data dependency analysis by modeling variable definitions and references. It also handles multithreading programs and exceptions by modeling relevant events. The authors implemented this method in a tool called Reticella as an Eclipse plugin, and demonstrate its applicability through case studies on Java programs.

Uploaded by

Lau Cerise
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views8 pages

How To Draw Diagram - Noda

This document proposes a sequence diagram slicing method that extends the authors' previous work. The proposed method allows for more precise data dependency analysis by modeling variable definitions and references. It also handles multithreading programs and exceptions by modeling relevant events. The authors implemented this method in a tool called Reticella as an Eclipse plugin, and demonstrate its applicability through case studies on Java programs.

Uploaded by

Lau Cerise
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Sequence Diagram Slicing

Kunihiro NODA∗ , Takashi KOBAYASHI† , Kiyoshi AGUSA‡ Shinichiro YAMAMOTO


Graduate School of Information Science Faculty of Information Science and Technology
Nagoya University Aichi Prefectural University
Nagoya, Aichi, 464-8601, Japan Aichi-gun, Aichi, 480-1198, Japan
Email: ∗ [email protected], Email: [email protected]
{† tkobaya, ‡ agusa}@is.nagoya-u.ac.jp

Abstract—Software visualization with sequence diagrams is diagram of a size that is reduced but sufficient for easy
one of the promising techniques aimed at helping developers understanding.
comprehend the behavior of object-oriented systems effectively.
However, it is still difficult to understand this behavior, because Several methods and tools [4], [5] have been proposed to
the size of automatically generated sequence diagrams tends provide sequence diagrams with easy-to-understand focused
to be beyond the developer’s capacity. behavior by reducing the amount of execution information
In this paper, we propose a sequence diagram slicing method, to be visualized. We have also developed a method for
which is an extension of our previous method based on providing a “partial sequence diagram” whose size is small
a dynamic slicing technique using static information. Our
proposed method is capable of accurate slice calculation based enough to make the focused behavior of a program easy to
on high-precision data dependency and can support various understand by applying the program slicing technique [6].
programs, including exceptions and multithreading. However, in our previously proposed method, information
In addition, our proposed new tool performs slice cal- that should be contained in a slice may be missed, because
culations on the Eclipse platform and we demonstrate the we used approximated data dependency. The method also
applicability of this method by applying the tool to two Java
programs as case studies. The results confirm the effectiveness has strong limitations when applied to programs; for exam-
of our proposed method for understanding the behavior of ple, it only supports Java 1.4 and does not cover multithread
object-oriented systems. and exception occurrence programs.
Keywords-Sequence Diagram; Program Slicing; Reverse En- In this paper we propose a sequence diagram slicing
gineering; Program Comprehension; Program Maintenance; method, which extends our previous model and method,
Debugging analyzes data dependency more precisely and handles the
information about thread and exception to acquire the capa-
I. I NTRODUCTION bility to be used in a wider range of applications. We also
introduce our new tool “Reticella” that visualizes object-
Understanding the behavior of a large-scale object-
oriented program’s behavior and supports sequence diagram
oriented system is one of the more difficult tasks of program
slicing, which is implemented as an Eclipse plug-in. In
comprehension. Object-oriented programs tend to contain
addition, we discuss the applicability of the proposed method
many elements that are determined at the time of execution,
with two case studies.
because design patterns, polymorphism and delegation are
often used to improve changeability and reusability of their This paper makes the following major contributions.
source codes.
• We clearly define data dependency calculations for ex-
Visualization of interactions between objects is one of ecution traces with static control structure information.
the promising techniques to help developers comprehend • We propose a model to represent the behavior of a
the behavior of object-oriented systems effectively [1] . A multithread program that includes exception handling.
sequence diagram is a diagram that represents the sequence • We show the feasibility of the proposed method with
of messages passing of programs along a time line and an implemented tool as an Eclipse plug-in that supports
is suitable for representing the behavior of object-oriented all major features of Java programs.
programs. Several tools [2], [3] support automatic generation
of a sequence diagram from execution trace logs. However, The remainder of this paper is organized as follows. Sec-
it is still difficult to understand this behavior because the tion 2 shows our preliminary work to support comprehension
size of automatically generated sequence diagrams tends to of the program’s behavior. We explain our proposed method
be beyond the developer’s capacity. in Section 3 and our implemented tool in Section 4. Section
The purpose of this research is to help the developer un- 5 shows case studies. Section 6 discusses related works and
derstand the behavior of programs by providing a sequence Section 7 concludes this paper.
II. P RELIMINARY W ORK First, we describe the extension to analyze data depen-
We have proposed a method and a tool for generating a dency more precisely. In our previous method, the data
partial sequence diagram [7]. dependency arising by assignment expression cannot be
In our previous work, we have defined the simplified analyzed, because the B-model in our previous method does
Behavior Model (B-model). The B-model represents the not contain information that reflects data flow related to
execution behavior of object-oriented programs and consists values of variables. In the proposed method, to analyze data
of execution information, method entry/exit events, caller/- flow related to values of variables, we model two events,
callee objects of method invocation and start/end events ‘definition of’ and ‘reference to’ the value of the variable
of control structure such as a conditional branch and a during execution of the programs, and add the models to
loop statement. Elements of the B-model can be uniquely the B-model. We call these two events VariableDefinition or
converted to elements of a sequence diagram. VariableReference, respectively.
The tool generates B-model data from source codes Second, we describe the extension for covering programs
and execution traces, and calculates a subset of the B- that contain exception occurrences. There are two types of
model data for a partial sequence diagram by adapting our information about exceptions, exception occurrence and ex-
slicing method based on Dependence-Cache Slicing [8]. ception handling. To cover programs that contain exception
The proposed tool was implemented by using JavaCC [9] occurrences, we modelled seven events, exception occur-
to statically analyze the control structure in source codes, rence and start/end of try/catch/finally clause, and added
and JDI (Java Debug Interface) in JPDA (Java Platform these models to the B-model.
Debugger Architecture) to dynamically analyze how the Third, we describe the extension to cover multithread pro-
program is being executed. grams. We need information about a thread in which an event
We analyze the following four kinds of dependencies occurs to analyze programs that contain multithreading. We
in a data sequence based on the B-model that represents modelled two details about a thread, its ID and its name,
execution behavior. and made elements of the B-model to hold this information
• Control Dependency. as attributes.
A dependency that reflects control flow in programs. Finally, we describe the extension to choose slicing cri-
• Method Invocation Dependency. teria more flexibly. We made elements of the B-model to
A dependency that reflects a nested structure of method hold information about variables that can be referred to at
invocations. the point of the occurrence of an event as attributes. By
• Start–End Dependency. providing information about the variables when choosing
A dependency that associates a start event with a slicing criteria, it has become possible to choose slicing
corresponding end event in the B-model. criteria more flexible than those chosen using our previous
• Data Dependency. method.
An approximate dependency between B-model data that We represent a program behavior in a data sequence
reflects data flow in programs. hb1 , b2 , · · · , bn i, where bi (1 ≤ i ≤ n) is a leaf element
of the tree whose root is BehaviorEvent in Fig. 1 (e.g.
III. P ROPOSED M ETHOD
MethodEntry, ConditionEnd, ExceptionOccurrence, TryS-
In this paper, we propose a sequence diagram slicing tart, VariableDefinition, etc.). For any i, bi can be converted
method that expands our previous method mentioned in to an element of a sequence diagram uniquely. MethodEntry
Sect. II with respect to the B-model and definitions of depen- and ConstructorEntry correspond to ‘a synchronous mes-
dencies. The newly proposed method enables the following sage’ and ‘a object creation message’ respectively, and both
four types of content. MethodExit and ConstructorExit correspond to a reply mes-
• Slice calculation based on high-precision data depen- sage in a sequence diagram. Other leaf elements except for
dency. VariableDefinition and VariableReference are depicted using
• Handling programs containing exception occurrences. a comment (i.e. a note symbol) in a sequence diagram. Both
• Handling multithread programs. VariableDefinition and VariableReference are not depicted in
• Flexible choice of slicing criteria. a sequence diagram.
In the following, we explain the detail of extensions in the
proposed method to achieve the abovementioned four types B. Extension of Data Dependency
of content.
We redefined data dependency to analyze data depen-
A. Extension of Behavior Model dencies more precisely. In this section we explain the new
In this section, we explain the detail of extension of the B- definition of data dependency in the proposed method.
model. The class diagram of the extended B-model is shown As mentioned earlier in Sect. III-A, we added two ele-
in Fig. 1. ments related to the value of variables to B-model, namely
Behavior
VariableInfo # value ValueInfo
MethodSignature # variableName : String
- returnType : String 1 1
- methodName : String 1
- argumentTypeList : List <String> 0..* - behaviorEventList
ThreadInfo ObjectInfo PrimitiveValueInfo
# theadInfo BehaviorEvent LocalVariableInfo FieldInfo
- threadID : Integer - ownerObject - objectID : Integer - typeName : String
1 # methodSignature # eventNumber : Integer
- threadName : String 1 1 1 1 - className : String

MethodEvent ConditionEvent ExceptionEvent VariableEvent


# callerObj : ObjectInfo # conditionString : String # visibleVariableList : List<VariableInfo>
# calleeObj : ObjectInfo # visibleVariableList : List<VariableInfo>
# callerVisibleVariableList : List<VariableInfo>
1
# calleeVisibleVariableList : List<VariableInfo>
ExceptionOccurrence ExceptionHandlingEvent VariableDefinition VariableReference
ConditionStartEvent ConditionEndEvent - thrownExceptionName : String - definedVariable : VariableInfo - referredVariable : VariableInfo
# evaluatedValue : ValueInfo

EntryEvent ExitEvent
# argumentValueList : List<ValueInfo>
ExceptionHandlingStartEvent ExceptionHandlingEndEvent
ConditionStart LoopStart Looping ConditionEnd LoopEnd
- loopCount : Integer

MethodEntry ConstructorEntry MethodExit ConstructorExit


- returnValue : ValueInfo TryStart CatchStart FinallyStart TryEnd CatchEnd FinallyEnd
- caughtException : String - caughtException : String

Figure 1. Class diagram of extended B-model

VariableDefinition and VariableReference. Thus, a data se- variable t.


quence based on the extended B-model that represents the – bj is the VariableReference of variable t that is
program’s behavior holds information that reflects the data referred to by using variable v like v.t.
flow caused by defining of or referring to values of variables. – bj is the VariableReference of variable t and vari-
In addition, the information is sufficient for analyzing the able t is referred to with variable v as the index of
data dependencies that arise by assignment expression that the array.
cannot be analyzed using our previous method. – bj is ExceptionOccurrence that was occurred by a
In what follows, we assume that the execution behav- throw statement and variable v is referred at the
ior of a program is represented in the data sequence throw statement.
hb1 , b2 , · · · , bn i, where bi (1 ≤ i ≤ n) is an element in the Finally, we define data dependencies that arise along
B-model, and that 1 ≤ i, j ≤ n and i < j hold. with ‘method’ and ‘constructor’ invocations. In method and
We define five kinds of data dependency to achieve high- constructor invocation we should consider data flow about
precision data dependence analysis. arguments and a return values. Note that we consider that
First, we define data dependency that exists from Vari- the constructor has a return value of reference to an object,
ableDefinition to VariableReference, as follows. which is generated by the constructor invocation. Therefore,
Definition 1. If the following three conditions hold, there there are two kinds of data flow regarding a return value,
exists data dependency from bi to bj . that occur at the ‘method exit’ and ‘constructor exit’ events.
• bi is an event of VariableDefinition of the variable v. We define three kinds of data dependencies regarding the
• bj is an event of VariableReference of the variable v, argument and the return value of method and constructor
and the definition of the value of variable v at bi reaches invocation, as follows.
the event occurrence point at bj . Definition 3. When entering ‘method’, formal parameters
Second, we define data dependency that exists from are defined by using values of the actual parameters. Thus,
VariableReference to another event, as follows. there exists data dependency from the VariableReferences
Definition 2. If the following condition holds, there exists of each actual parameter to the VariableDefinitions of each
data dependency from bi to bj . formal parameters respectively.
• Variable v is referred to at the VariableReference event Definition 4. We create a variable whose name is unique
bi when executing event bj . during execution of the program per method invocation.
Note that one of the following conditions holds iff we When exiting from ‘method’ we consider that the value of
say that variable v is referred to when executing an the unique variable is defined by a return value. Thus, there
event bj . exists data dependency from the VariableReference of the
– bj is an event of method entry and the variable v variables that affects the return value to the VariableDefini-
is referred to as v.method(). tion of the unique variable. Using the return value generates
– bj is an event of the start of the control structure the VariableReference of the unique variable.
and variable v is referred to as the predicate of the Definition 5. We create a variable whose name is unique
event bj . during execution of program per constructor invocation.
– bj is the VariableDefinition of variable t and vari- When exiting from the ‘constructor’, the value of the unique
able v is referred to when defining the value of variable is defined by reference to an object generated by the
constructor invocation. Thus, there exists data dependency Formatted
from the ‘constructor exit’ event (i.e. ConstructorExit) to Java Source
Codes
Static Analyser BPDG

VariableDefinition of the unique variable. Reference to the Static


execute
compile & Slicer
generated object generates the VariableReference of the Information
analyze

unique variable. Class Files Tracer Drawer


a slice of
sequence
diagram
C. Extension of Other Dependencies
Along with extending the B-model, we also extended the Figure 2. Overview of the tool
other three dependencies in our previous method. By making
these extensions, it becomes possible to handle programs
containing exception occurrences and multi-threading and of a program is represented by a B-model data sequence
choose slicing criteria more flexibly. hb1 , b2 , · · · , bn i and the slicing criterion is (bc , V ), where
Control Dependency. In our proposed method we defined V is a set of variables that are capable of being referred
three kinds of control dependencies concerning the newly to at the point at which bc is executed. The slice of a
added B-model elements related to exception, as follows. sequence diagram is calculated on a dependence graph we
• If the following two conditions hold, there exists control called BPDG, whose nodes are B-model elements, and its
dependency from bi to bj . edges are based on dependencies defined in Sect. III-B and
– bi is ConditionStart/LoopStart/Looping. Sect. III-C. A slice calculation proceeds as follows.
– Decision on whether bj is executed or not depends 1) For each v ∈ V , we traverse the sequence
on the result of evaluation of the predicate of bi . hb1 , b2 , · · · , bn i backwards, that is towards the event
• If the following two conditions hold, there exists control that occurred first in the execution of the program
dependency from bi to bj . to find VariableDefinitions bvi (1 ≤ i < c), where bvi
– bi is TryStart/CatchStart/FinallyStart. represents the VariableDefinition of v and occurs ith
– Decision on whether bj is executed or not depends during the program execution. Here, v and bvi need to
on whether bi is generated. satisfy either of the following two conditions.
v
• If the following two conditions hold, there exists control • v is a local variable, and the bi and bc occurred

dependency from bi to bj . on the same thread.


• v is a field.
– bi is the ExceptionOccurrence.
– bj is the CatchStart which catches the exception 2) We assume that Bdef is a set of bvi for each v ∈ V .
that occurred at bi . For each bvi ∈ Bdef , we start slice calculation from
Method Invocation Dependency. Concerning newly the node bvi by traversing the edges backward on the
added thread’s information, in our proposed method we BPDG.
define ‘method invocation dependency’ as follows. 3) The set of nodes which are reached by our traversal on
the BPDG are the slice. Hence, the slice is a B-model
• If the following three conditions hold, there exists
data sequence and can be converted to a sequence
method invocation dependency from bi to bj .
diagram.
– bi is MethodEntry/ConstructorEntry. 4) Finally, by converting the slice of B-model data se-
– bj occurred before the exit event that corresponds quence to a sequence diagram, we get a slice of a
to bi occurring, or bj is MethodExit/Construc- sequence diagram.
torExit that corresponds to bi .
– Both bi and bj are events that occurred on the same IV. I MPLEMENTED TOOL : R ETICELLA
thread.
In this study, we developed a tool for effective visual-
Start–End Dependency. Concerning the newly added ization of a Java program with sequence diagram, which is
information in relation to exception, in our proposed method called Reticella. The developed tool is capable of calculating
we define Start–End Dependency as follows. a slice of a sequence diagram based on the proposed method
• If the following two conditions hold, there exists start– as an Eclipse plug-in. The tool consists of four parts; static
end dependency from bi to bj . analyzer, tracer, slicer and drawer. An overview of the tool is
– bi is entry/start event. shown in Fig. 2. The developed tool calculates and generates
– bj is exit/end event that corresponds to bi . a slice of sequence diagram automatically. However, for
static analysis, before applying our tool to target programs,
D. How to Calculate a Slice of Sequence Diagram the source codes need to be formatted manually by the
In this section, we explain how to calculate a slice of the Eclipse built-in formatter. This operation is needed only
sequence diagram. We assume that the execution behavior once, at the first time. After this the operation needs to be
repeated only if the source codes are modified. Our tool’s With respect to understandability, the tracer collects only
slice calculation proceeds as follows. information related to user codes; the tracer does not collect
1) The static analyzer analyzes source codes and acquires information related to libraries’ codes.
static information. The slicer calculates a slice by backward traversal on the
2) The tracer receives the static information and class BPDG using a slicing criterion inputted by the user, based
files of the target program as an input and executes the on algorithm shown at Sect. III-D.
programs with a specific program’s input. The tracer
B. Static Analyzer
constructs the BPDG based on the static information
received from the static analyzer and the dynamic To obtain information that cannot be acquired by JDI
information acquired during program execution. and generate model data based on the extended B-model,
3) Our tool extracts from the BPDG a data sequence we developed the static analyzer using the information of
based on the B-model, which represents the whole the abstract syntax tree (AST) in Eclipse JDT. The static
behavior of programs and converts the data sequence analyzer converts source codes to AST representation and
to a sequence diagram. This is then provided to the analyzes the latter.
user by the tool, using drawer. The static analyzer analyzes mainly the Statement and
4) The user looks at the sequence diagram, chooses a Expression nodes in AST, which correspond to statement
slicing criterion and inputs it into the slicer. and expression in Java language respectively. The static
5) The slicer extracts a slice from the BPDG based on analyzer analyzes what a data sequence based on the B-
the slicing criterion. Then, the drawer provides it to model should be generated when statement and expression
the user as a slice of a sequence diagram. are executed for all statements and expressions in a program
beforehand. That is, the static analyzer makes skeletons of
In what follows, we explain the details of the components
B-model data sequences before a program is executed. The
of our developed tool.
analyzed information is passed to the tracer, which then
A. Tracer & Slicer generates a data sequence based on the B-model.
The tracer executes the program based on a specified C. Drawer
program’s input and collects information about how the The drawer draws a sequence diagram and provides it
program is being executed. to the user. We used the Quick Sequence Diagram Editor
We implemented a tracer by using a JDI to examine [10] to draw a sequence diagram in a drawer. The Quick
how the program is being executed on Java VM. JDI is Sequence Diagram Editor receives text data, which is for-
a frontend of JPDA. JDI can access a VM that is being matted based on a specific syntax as an input, then converts it
executed and examine and control the inner states of the to a sequence diagram and displays it. The drawer converts
VM, such as receiving the notification of method entry/exit a data sequence based on the extended B-model to input
and setting the breakpoint to a specific bytecode. JDI also form of Quick Sequence Diagram Editor and displays a
enables the acquisition of various pieces of information such sequence diagram by inputting the converted data into the
as information on the state of a stack frame per method Quick Sequence Diagram Editor. Then, the drawer provides
invocation. the sequence diagram to the user.
The tracer captures the following events related to the B-
model by using APIs of JDI and generates B-model data D. Limitation
along with the time line. Unfortunately, our tool still has some limitations, as
• Entry and exit events of method and constructor. described in the following.
• Events of exception occurrence. • Some elements in Java are not covered, for example
• Events of definition and reference of the field’s value. enhanced for statement and reflection.
Other events listed above, for example start/end events • Information that needs to be evaluated dynamically
of the control structure and VariableDefinition/VariableRef- when the execution of a program is not analyzed, for
erence of local variables, cannot be captured only by JDI. example, the index of array and short circuit operator.
To capture these events, we use the functions of setting the • The analysis of the tool depends on the form of
breakpoint at specific bytecodes in class files and notifying bytecodes in class files and the tool cannot analyze
the event of the program counter reaching the breakpoint statements that have no bytecode.
location, which are provided by JDI. In our tool, we set
breakpoints at every statement and part of a statement in a V. C ASE S TUDIES
program to know which locations in a program are executed. To evaluate the effectiveness of our proposed method, we
By doing this, we generate the B-model events that cannot applied the tool to two Java programs as case studies. In this
be captured by JDI. section, we describe the case studies in detail.
1 package ex1;
2 public class Class1 {
3 private int field;
4 public static void main(String[] args) {
5 Class1 obj1 = new Class1();
6 obj1.setField(−1);
7 try {
8 obj1.m1();
9 obj1.m2();
10 } catch (IllegalStateException e) {
11 e.printStackTrace();
12 }
13 }
14 public void setField(int field) {
15 this.field = field;
16 }
17 public void m1() {
18 System.out.println(this.field);
19 }
20 public void m2() throws IllegalStateException {
21 if (this.field < 0) {
22 throw new IllegalStateException();
23 } else {
24 // perform some action using positive value of field.
25 }
26 }
27 }

Figure 3. Source code of program 1 Figure 4. Sequence diagram that represent the whole execution behavior
of program 1 shown at Fig. 3.

A. Case Study 1
By using our developed tool explained in Sect. IV, we
visualized the program shown in Fig. 3 as a sequence
diagram. As a result, we got the sequence diagram shown in
Fig. 4, which represents the whole execution behavior of the
program. In Fig. 4, the number between ’[’ and ’]’ indicates
that the event occurred ith in the execution of the program.
For the slicing criterion (bc , v), the number c is chosen from
numbers between ’[’ and ’]’. In Fig. 4, we used a special
lifeline whose name is “static#:FullyQualifiedClassName”,
where # is an arbitrary unique number per class, because a
static method does not have a callee object.
In the sequence diagram shown in Fig. 4, an exception
of the class “IllegalStateException” has occurred at event
number [35] and the exception was caught by a catch clause
at event number [39].
To detect what program behavior caused the exception,
we chose (b42 , e) as the slicing criterion, where the variable
e is able to be referred at the caller stackframe of b42 , and Figure 5. Slice of a sequence diagram shown at Fig. 4 by slicing criterion
sliced the sequence diagram shown at Fig. 4. (b42 , e).
As a result of slicing, we obtained a slice of the sequence
diagram, which is shown in Fig. 5. In the program shown
at Fig. 3, IllegalStateException has been thrown because: From this result, we confirmed that the data dependency
first, a negative integer value was assigned to f ield at arising from the assignment expression and the unusual
line 16; and second, the predicate of the if statement at control flow that occurs by exception occurrence—both of
line 20 was evaluated as true; and finally, the throw which could not be analyzed by our previous method—were
statement at line 21 was executed. The information that now correctly analyzed. Moreover our proposed method is
caused exception occurrence was indeed included in the also expected to facilitate developers’ tasks for large-scale
slice shown in Fig. 5 and information irrelevant to the programs by effectively providing useful information for
occurrence of exception, such as method invocation of m1 understanding the program’s complex behavior and time-
and println, was deleted and does not exist in the slice. consuming debuggings as a sequence diagram.
proposed method has the capability to extract appropriately
only information of interest that exists in several threads.
Hence, our proposed method could become a valuable aid to
support program comprehension and software maintenance.
VI. R ELATED W ORK
A reverse-engineered sequence diagram is a very useful
tool for software development such as comprehension of
a program’s behavior, software maintenance and debug-
ging. There are many works and tools related to reverse-
engineered sequence diagrams [11].
However, as mentioned in Sect. I, to simply generate
a reverse-engineered sequence diagram from the execution
trace may lead developers into difficulties, because of the
large size of the diagram. To solve the problem, several
works have proposed effective software visualization meth-
Figure 6. Slice of a sequence diagram shown at Appendix 1 by slicing ods and tools.
criterion (b158 , num). Sharp et al. discuss the visual limitations and propose
techniques to help developers explore large-scale reverse-
engineered sequence diagrams [12]. By filtering out infor-
B. Case Study 2 mation of no interest, and allowing the user to select and ex-
In this section, we show an application of our pro- amine details of messages on demand, effective exploration
posed method to a multithread program. We chose a Con- of the sequence diagram is achieved.
sumer/Producer problem, which is typical multithreading Taniguchi et al. propose a method of compressing a
problem, as the subject of the case study. sequence diagram and improving its readability. [4]. If rep-
In the program we used in this case study, a Consumer etitions and recursive method calls exist in a program, same
class gets the value of common buffer by getV alue method or similar method invocation patterns are expected to appear
and assigns the value to a variable num. Therefore, we in a reverse-engineered sequence diagram. In Taniguchi’s
chose (b158 , num) as the slicing criterion to examine what method, the patterns are visualized in compressed form, and
behaviors affect the value of the common buffer. Note that thus the readability of the sequence diagram improves.
the event b158 is a method entry event for printing the value AMIDA [5] is a tool for generating sequence diagrams
of num, after a second access of Producer/Consumer to the that represent the execution behavior of a program. AMIDA
common buffer, and the variable num is a local variable can perform automatic phase detection and separate a lot
which can be referred at the caller stackframe of b158 . of execution information to several parts corresponding to
A generated sequence diagram that represents the whole features, and provides visualized information effectively.
execution behavior of the Consumer/Producer program is JSlice [13] is one of the famous dynamic slicing tools for
shown in Appendix 1. In the diagram, two sets of access to Java programs. It collects and analyzes bytecode traces with
the common buffer are depicted. In the first set, the Producer lossless data compression, and improves space efficiency.
stored a value to the common buffer first and the Consumer
got the value from the common buffer first. In the second set, VII. C ONCLUSION AND F UTURE W ORK
there is second access to the common buffer by the Producer In this study, we proposed a sequence diagram slicing
and Consumer. method that extracts points of interest and parts related to
The result of slicing by slicing criterion (b158 , num) is them from a sequence diagram that represents the whole be-
shown in Fig. 6. The resulting diagram contains information havior of programs. The proposed method can perform slice
about a Producer storing a value to the common buffer calculation more correctly on the basis of high-precision data
secondly and a Consumer getting the value from the com- dependency and cover a larger variety of Java programs by
mon buffer secondly, and it does not contain information extending our previous method.
about the first set of accesses to the common buffer by We developed a tool that calculates a slice based on our
the Consumer and Producer. Therefore, only the information proposed method. Using the tool, we applied the proposed
related to the slicing criterion is correctly extracted in the method to two kinds of Java programs. The result confirmed
slice. that our proposed method 1) can reduce the size of informa-
There are many concurrent applications in recent year and tion in a sequence diagram appropriately, and 2) is effective
because of the complexity of the behavior, comprehending to support developers’ tasks, such as comprehension of a
the behavior of these applications is a tough task. Our program’s behavior and debugging.
Our plans for future work and challenges are as follows. [10] M. Strauch, “Quick Sequence Diagram Editor,” http://sdedit.
sourceforge.net/.
• More reduction in the information included in a slice
[11] C. Bennett, D. Myers, M.-A. Storey, D. M. German, D. Ouel-
of a sequence diagram.
let, M. Salois, and P. Charland, “A survey and evaluation of
Some approaches are expected to be effective in this tool features for understanding reverse-engineered sequence
challenge, for example using the method for com- diagrams,” J. Softw. Maint. Evol., vol. 20, no. 4, pp. 291–315,
pressing a sequence diagram together [4], introducing 2008.
interactive representation of a sequence diagram like [12] R. Sharp and A. Rountev, “Interactive exploration of uml
[12], and improving and refining our slicing algorithm sequence diagrams,” in VISSOFT ’05, pp. 1–6.
by introducing new dependencies. Moreover, filtering [13] T. Wang and A. Roychoudhury, “Using Compressed Bytecode
Traces for Slicing Java Programs,” in ICSE ’04, pp. 512–521.
out useless and unwanted information before tracing
[14] H. Zhong, L. Zhang, and H. Mei, “Early Filtering of Polluting
like [14] is also expected to be effective in improving
Method Calls for Mining Temporal Specifications,” in APSEC
the readability of the diagram and analyzing time ’08, pp. 9–16.
efficiency.
• Effective representation of multithread programs on a
sequence diagram.
Depicting several threads’ behavior in a program into a
single sequence diagram tends to lead to more complex-
ities and reduce the readability of the sequence diagram.
Therefore, we need to introduce some new methods that
cope with such problems, for example, grouping threads
that are related to each other and three-dimensional
representation of a sequence diagram.

ACKNOWLEDGMENT
We would like to thank Dr. Motoshi Saeki, Junya Katada
and Masashi Shikauchi for their comments. This work is
partially supported by a Grant-in-Aid for Scientific Research
of MEXT Japan (# 20300009, # 21700027).

R EFERENCES
[1] L. C. Briand, Y. Labiche, and J. Leduc, “Toward the Reverse
Engineering of UML Sequence Diagrams for Distributed Java
Software,” IEEE Trans. Softw. Eng., vol. 32, no. 9, pp. 642–
663, 2006.
[2] W. D. Pauw, E. Jensen, N. Mitchell, G. Sevitsky, J. M.
Vlissides, and J. Yang, “Visualizing the Execution of Java
Programs,” in Software Visualization (LNCS Vol.2269), 2002,
pp. 151–162.
[3] J. Kern and C. Garrett, “Effective sequence diagram gener-
ation,” Borrand White paper, 2003, http://www.borland.com/
resources/en/pdf/white papers/20263.pdf.
[4] K. Taniguchi, T. Ishio, T. Kamiya, S. Kusumoto, and K. In-
oue, “Extracting Sequence Diagram from Execution Trace of
Java Program,” in IWPSE ’05, pp. 148–154.
[5] T. Ishio, Y. Watanabe, and K. Inoue, “AMIDA: a Sequence
Diagram Extraction Toolkit Supporting Automatic Phase De-
tection,” in Proc. ICSE Companion ’08, pp. 969–970.
[6] M. Weiser, “Program Slicing,” in ICSE ’81, pp. 439–449.
[7] J. Katada, T. Kobayashi, M. Shikauchi, and M. Saeki,
“Sequence diagram generator based on slicing technique
(poster),” Workshop on Eclipse Technology eXchange, 2004,
http://www.se.cs.titech.ac.jp/research/sdg/index.html.en.
[8] T. Takada, F. Ohata, and K. Inoue, “Dependence-cache slic-
ing: A program slicing method using lightweight dynamic
information,” in IWPC ’02, pp. 169–177.
Appendix 1. Sequence diagram which represents the whole execution
[9] “JavaCC,” https://javacc.dev.java.net/. behavior of a Consumer/Producer program.

You might also like