IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science...
-
Upload
donald-page -
Category
Documents
-
view
213 -
download
0
Transcript of IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science...
![Page 1: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/1.jpg)
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMSMartin Görg and Jianjun Zhao
Computer Science Department, Shanghai Jiao Tong University
![Page 2: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/2.jpg)
Outline
Motivation and Background Difference Analysis Algorithm Evaluation of Quality and Feasibility Conclusions
![Page 3: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/3.jpg)
Motivation and Background
![Page 4: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/4.jpg)
Static Semantic Difference Analysis
static: source code analysis at compile time
semantic: differences in behavior
P P’modified
![Page 5: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/5.jpg)
Why solve the Problem?
Motivation Reduce testing costs Produce correct software
Possible applications Debugging support Regression test selection Program slicing
![Page 6: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/6.jpg)
AOP and AspectJ
AOP encapsulates crosscutting concerns AspectJ
implementation of AOP extension to Java
public class C { int i;
void m1() { } …}
Base Code
aspect A { double C.d;
before() : … { } ….}
Aspect Code
Introduce
Advise
![Page 7: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/7.jpg)
AspectJ Example
1 aspect Constraints {
2 public boolean Shape.immovable = false;
2 void around(Shape s) : execution (public Shape+.set*(..)) && target(s)
{
3 if (!s.immovable) {proceed( ) ; } }
}
ITD
around advice
![Page 8: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/8.jpg)
Hammocks
Single entry Single exit For any directed graph
S
E
![Page 9: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/9.jpg)
Motivational Example
1 public class Point extends Shape {
2 private int x, y;
3 public void setX(int i){
4 x = i;
}
5 public void setY(int i){
6 y = i;
}
1 public class Point extends Shape {
2 private int x, y;
3 public void setX(int i){
4 x = i;
}
5 void setY(int i){
6 y = i;
}
a change in visibility alters program execution
![Page 10: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/10.jpg)
for AspectJ Programs
Difference Analysis Algorithm
![Page 11: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/11.jpg)
Algorithm Outline
1. For every module in P find a matching module in P’ (module-level matching)
2. Build extended CFGs for all modules in P and P’ and identify hammocks
3. Perform node-by-node comparison on every pair of hammock graphs (node-level matching)
![Page 12: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/12.jpg)
Matching at Module Level
Signature matching
Disjunctive matching
Obtain best match from multiple candidates
public void p1.C1.add(int, Object)P: boolean p1.C1.add(int, Object)P’:
public void p1.C1.add(int, Object)P: boolean p1.C1.add(double, Object)P’:
![Page 13: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/13.jpg)
1. Matching at Module Level
Problem: Not every AspectJ construct has a signature (most importantly: advices)
Solution:a) Define new AspectJ signatures
(e.g. [strictfp] before (Formals) :
[throws TypeList] : Pointcut {Body})b) Define disjunctive patterns for these
signatures
![Page 14: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/14.jpg)
2. Build CFGs and Hammocks
![Page 15: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/15.jpg)
3. Matching at Node Level
Simultaneous graph traversal Node-by-node comparison Recursive Two user inputs
Similarity threshold (S) Maximum lookahead (LH)
![Page 16: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/16.jpg)
3. Matching at Node Level
X
E
Y
H
P
X
E
Y
H
P’
S
U V
e
P
S
U V’
e
P’
Similarity Threshold S = 0.5; Lookahead LH = 1
![Page 17: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/17.jpg)
Quality and Feasibility
Tests and Evaluation
![Page 18: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/18.jpg)
Program LOC Diffs Affected Matched Errors
ants 1451
4 26 2446 (100%)
0
bean 199 19 30 268 (100%) 0
cona-stack 381 1 9 730 (100%) 0
dcm 3140
684 1523 2771 (100%)
0
figure 148 42 101 177 (100%) 0
introduction
233 4 18 362 (98.3%)
6
nullcheck 2980
136 258 2828 (98.2%)
78
quicksort 115 14 27 155 (100%) 0
spacewar 3053
1 283 4496 (100%)
0
tracing 330 55 164 442 (100%) 0
Signature definitions and disjunctive matching Minimal change with maximal effect Deficits: some combinations and swapped
statements
![Page 19: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/19.jpg)
S < 0.6: LH has only minor impact LH 20: within one minute S 0.6: slow for LH > 20, but not needed
0 10 20 30
1
10
100
1,000
10,000
100,000
1,000,000
10,000,000
Performance results
Similarity = 0.0Similarity = 0.6
Similarity = 1.0
Lookahead
tim
e (
ms)
sca
led
to l
og
![Page 20: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/20.jpg)
New Findings and Open Tasks
Conclusions
![Page 21: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/21.jpg)
What we did
New signatures for AspectJ modules Disjunctive matching
for AspectJ and Java modules a solution for modified signatures
Application of hammock algorithm from OO to AO
Evaluations using a tool implementation
![Page 22: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/22.jpg)
Conclusions
Disjunctive matching is a good idea modules are correctly matched more work for node-level matching eliminates work of type-level matching replaces user interaction
Type-level matching is not required Hammock graph matching can be applied
given:a) correctly matched modulesb) appropriately modeled and labeled CFGs
![Page 23: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/23.jpg)
Future Work
Improve disjunctive matching patterns Extend CFG representations Solve the swapping problem Handle dynamic pointcuts
![Page 24: IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.](https://reader035.fdocuments.in/reader035/viewer/2022062803/56649f325503460f94c4ebbb/html5/thumbnails/24.jpg)
Questions?
Thank You for listening