identifying semantic differences in aspectj programs

24
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University

Upload: katina

Post on 25-Feb-2016

41 views

Category:

Documents


0 download

DESCRIPTION

Identifying Semantic Differences in AspectJ Programs. Martin G ö rg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University. Outline. Motivation and Background Difference Analysis Algorithm Evaluation of Quality and Feasibilit y Conclusions. Motivation and Background. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Identifying Semantic Differences in AspectJ Programs

IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMSMartin Görg and Jianjun ZhaoComputer Science Department, Shanghai Jiao Tong University

Page 2: Identifying Semantic Differences in AspectJ Programs

Outline

Motivation and Background Difference Analysis Algorithm Evaluation of Quality and Feasibility Conclusions

Page 3: Identifying Semantic Differences in AspectJ Programs

Motivation and Background

Page 4: Identifying Semantic Differences in AspectJ Programs

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

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

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

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( ) ; }

} }

ITDaround advice

Page 8: Identifying Semantic Differences in AspectJ Programs

Hammocks

Single entry Single exit For any directed graph

S

E

Page 9: Identifying Semantic Differences in AspectJ Programs

Motivational Example1 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

for AspectJ Programs

Difference Analysis Algorithm

Page 11: Identifying Semantic Differences in AspectJ Programs

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

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

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

2. Build CFGs and Hammocks

Page 15: Identifying Semantic Differences in AspectJ Programs

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

3. Matching at Node Level

X

E

Y

H

PX

E

Y

H

P’

S

U V

e

PS

U V’

e

P’

Similarity Threshold S = 0.5; Lookahead LH = 1

Page 17: Identifying Semantic Differences in AspectJ Programs

Quality and Feasibility

Tests and Evaluation

Page 18: Identifying Semantic Differences in AspectJ Programs

Program LOC Diffs Affected Matched Errorsants 145

14 26 2446

(100%)0

bean 199 19 30 268 (100%) 0cona-stack 381 1 9 730 (100%) 0dcm 314

0684 1523 2771

(100%)0

figure 148 42 101 177 (100%) 0introduction

233 4 18 362 (98.3%)

6

nullcheck 2980

136 258 2828 (98.2%)

78

quicksort 115 14 27 155 (100%) 0spacewar 305

31 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

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 301

10

100

1,000

10,000

100,000

1,000,000

10,000,000

Performance results

Similarity = 0.0Similarity = 0.6Similarity = 1.0

Lookahead

time

(ms)

sca

led

to lo

g

Page 20: Identifying Semantic Differences in AspectJ Programs

New Findings and Open Tasks

Conclusions

Page 21: Identifying Semantic Differences in AspectJ Programs

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

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

Future Work

Improve disjunctive matching patterns Extend CFG representations Solve the swapping problem Handle dynamic pointcuts

Page 24: Identifying Semantic Differences in AspectJ Programs

Questions?

Thank You for listening