240 likes | 352 Vues
This paper explores static semantic difference analysis of AspectJ programs, aiming to reduce testing costs, improve software correctness, and assist in debugging. We present a novel difference analysis algorithm that builds extended control flow graphs (CFGs) for matching modules, implemented through disjunctive matching. By examining node-level similarities and employing a hammock algorithm, we identify semantic changes in behavior due to modifications. Our evaluations demonstrate the effectiveness and feasibility of the proposed approach, with promising applications in regression testing and program slicing.
E N D
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 Feasibility • Conclusions
Static Semantic Difference Analysis • static: source code analysis at compile time • semantic: differences in behavior modified P P’
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 Aspect Code Base Code aspect A { double C.d; before() : … { } …. } public class C { int i; void m1() { } … } Introduce Advise
AspectJ Example • aspect Constraints { • public boolean Shape.immovable = false; • void around(Shape s) :execution (public Shape+.set*(..))&& target(s) { • if (!s.immovable) {proceed( ) ; } } } ITD around advice
Hammocks • Single entry • Single exit • For any directed graph S E
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
Difference Analysis Algorithm for AspectJ Programs
Algorithm Outline • For every module in P find a matching module in P’ (module-level matching) • Build extended CFGs for all modules in P and P’ and identify hammocks • 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 P: P’: P: P’: public void p1.C1.add(int, Object) boolean p1.C1.add(int, Object) public void p1.C1.add(int, Object) boolean p1.C1.add(double, Object)
1. Matching at Module Level • Problem: Not every AspectJ construct has a signature (most importantly: advices) • Solution: • Define new AspectJ signatures(e.g.[strictfp] before (Formals) : [throws TypeList] : Pointcut {Body}) • Define disjunctive patterns for these signatures
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 Similarity Threshold S = 0.5; Lookahead LH = 1 P P’ X X P P’ S S H H U U V V’ E E e e Y Y
Tests and Evaluation Quality and Feasibility
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
Conclusions New Findings and Open Tasks
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: • correctly matched modules • appropriately modeled and labeled CFGs
Future Work • Improve disjunctive matching patterns • Extend CFG representations • Solve the swapping problem • Handle dynamic pointcuts
Thank You for listening Questions?