identifying semantic differences in aspectj programs

Post on 25-Feb-2016

41 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

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

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

Outline

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

Motivation and Background

Static Semantic Difference Analysis

static: source code analysis at compile time

semantic: differences in behavior

P P’modified

Why solve the Problem?

Motivation Reduce testing costs Produce correct software

Possible applications Debugging support Regression test selection Program slicing

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

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

Hammocks

Single entry Single exit For any directed graph

S

E

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

for AspectJ Programs

Difference Analysis Algorithm

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)

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’:

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

2. Build CFGs and Hammocks

3. Matching at Node Level

Simultaneous graph traversal Node-by-node comparison Recursive Two user inputs

Similarity threshold (S) Maximum lookahead (LH)

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

Quality and Feasibility

Tests and Evaluation

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

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

New Findings and Open Tasks

Conclusions

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

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

Future Work

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

Questions?

Thank You for listening

top related