Title: Proving%20aspect-oriented%20programming%20laws
1Proving aspect-oriented programming laws
Informatics Center Federal University of
Pernambuco Brazil
- Leonardo Cole
- Paulo Borba
- Alexandre Mota
- (lcn,phmb,acm_at_cin.ufpe.br)
2Deriving Refactorings
- Primitive laws of programming
- simple, localized, intuitive and easier to
understand - Two transformations
- Bi-directional
- Guarded by pre-conditions
- We compose the laws to
- Derive complex and global refactorings
- Verify that an existing refactoring
- preserves behaviour
3Make Aspect Privileged
4Problem
- Current definition relies on the simplicity and
intuition of the laws
It is necessary to formally prove the laws to
increase the confidence that they preserve
behaviour
5Solution
- Aspect-oriented semantics for Method Call
Interception (MCI) - Equivalence notion for aspect-oriented programs
6Outline
- AspectJ Laws
- MCI
- Equivalence Notion
- Add Before Execution Law
- Conclusions
7Add before-execution
(?) body does not declare or use local
variables body does not call super
8Example
public class Account private double balance
... public void debit(double amount)
Access.check(new Permission()) //debit
logic ... public aspect
PermissionAspect
9Applying Add Before-Execution Law
public class Account private double balance
... public void debit(double amount)
//debit logic ... privileged aspect
PermissionAspect before(Account cthis, double
amount) execution(void Account.debit(double)
this(cthis) args(amount)
Access.check(new Permission())
10Summary of laws
Law Name Law Name
1 Add empty aspect 16 Remove argument parameter
2 Make aspect privileged 17 Add catch for softened exception
3 Add before-execution 18 Soften exception
4 Add before-call 19 Remove exception from throws clause
5 Add after-execution 20 Remove exception handling
6 Add after-call 21 Move exception handling to aspect
7 Add after returning-execution 22 Move field to aspect
8 Add after returning-call 23 Move method to aspect
9 Add after throwing-execution 24 Move implements declaration to aspect
10 Add after throwing-call 25 Move extends declaration to aspect
11 Add around-execution 26 Extract named pointcut
12 Add around-call 27 Use named pointcut
13 Merge advices 28 Move field introduction up to interface
14 Remove this parameter 29 Move method introduction up to interface
15 Remove target parameter 30 Remove method implementation
11Method Call Interception - MCI
- Operational semantics
- Extends an object-oriented language to introduce
aspect-oriented features - Superimpose construct
- On dispatch
- On enter
- On exit
12Domain Object-Store
13?O2 Call Rule
14MCI Call Rule
15Equivalence Notion
- We compare field values (heaps) resulting from
the two programs execution - Strong notion (equal heaps)
- Same number of objects
- Same number of fields
- Simplest notion to our objective
- The laws do not change programs data structure
First component of the object-store must be
equal for both programs
16Mapping AspectJ to MCI
- Before-call x On dispatch
- Before-execution x On enter
- After-execution x On exit
- args, this and target
- Aspect x Main method
17MCI Add Before Execution
18Evaluation Tree Left
19Evaluation Tree Right
20Comparing Trees
Circled nodes may update object-store
21Comparing
- Circled nodes are syntactically equal in both
sides - The order of execution is the same
- Pre-conditions not necessary for the MCI law
22Other Laws
- Add before-call
- Add after-execution returning
- Merge advices
- Remove target parameter
- Remove this parameter
23Conclusions
- Increase confidence that aspect-oriented
programming laws preserve behaviour - Equivalence notion for aspect-oriented programs
- Formal argumentation about the soundness of some
laws
24Conclusions
- Static semantics not considered
- Formal proof using induction
- Prove the remaining laws
- Extend MCI
- Choose another semantics
-
25Proving aspect-oriented programming laws
Informatics Center Federal University of
Pernambuco Brazil
- Leonardo Cole
- Paulo Borba
- Alexandre Mota
- (lcn,phmb,acm_at_cin.ufpe.br)
- Software Productivity Group
- http//www.cin.ufpe.br/spg
26Comparing Trees