Download presentation
Presentation is loading. Please wait.
Published byCorey Rogers Modified over 8 years ago
1
1 Proving aspect-oriented programming laws Leonardo Cole Paulo Borba Alexandre Mota (lcn,phmb,acm@cin.ufpe.br) Informatics Center Federal University of Pernambuco Brazil
2
2 Deriving 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
3
3 Make Aspect Privileged ts privileged aspect A { pcs as } = ( ) Advice bodies from as do not refer to private members declared in ts. ts aspect A { pcs as }
4
4 Problem 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
5
5 Solution Aspect-oriented semantics for Method Call Interception (MCI) Equivalence notion for aspect- oriented programs
6
6 Outline AspectJ Laws MCI Equivalence Notion Add Before Execution Law Conclusions
7
7 Add before-execution ts class C { fs ms T m(ps) { body’; body } ts class C { fs ms T m(ps) { body } = paspect A {... before(context) : exec(C.m) && bind(context) { body’ }... } paspect A {... } ( ) body’ does not declare or use local variables; body’ does not call super ; …
8
8 Example public class Account { private double balance;... public void debit(double amount) { Access.check(new Permission(…)); //debit logic }... } public aspect PermissionAspect { }
9
9 Applying 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(…)); }
10
10 Summary of laws LawNameLawName 1Add empty aspect16Remove argument parameter 2Make aspect privileged17Add catch for softened exception 3Add before-execution18Soften exception 4Add before-call19Remove exception from throws clause 5Add after-execution20Remove exception handling 6Add after-call21Move exception handling to aspect 7Add after returning-execution22Move field to aspect 8Add after returning-call23Move method to aspect 9Add after throwing-execution24Move implements declaration to aspect 10Add after throwing-call25Move extends declaration to aspect 11Add around-execution26Extract named pointcut 12Add around-call27Use named pointcut 13Merge advices28Move field introduction up to interface 14Remove this parameter29Move method introduction up to interface 15Remove target parameter30Remove method implementation
11
11 Method Call Interception - MCI Operational semantics Extends an object-oriented language to introduce aspect-oriented features Superimpose construct On dispatch On enter On exit
12
12 Domain: Object-Store
13
13 O 2 Call Rule
14
14 MCI Call Rule
15
15 Equivalence Notion We compare field values (heaps) resulting from the two program’s execution Strong notion (equal heaps) Same number of objects Same number of fields Simplest notion to our objective The laws do not change program’s data structure First component of the object-store must be equal for both programs
16
16 Mapping 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
17
17 MCI Add Before Execution ts class C { fs ms T m(ps) { body’; body } ts class C { fs ms T m(ps) { body } = class M { void main() { superimpose body’ on enter class C && method m && argument ps; sis; mainBody } class M { void main() { sis; mainBody }
18
18 Evaluation Tree: Left
19
19 Evaluation Tree: Right
20
20 Comparing Trees Circled nodes may update object-store
21
21 Comparing Circled nodes are syntactically equal in both sides The order of execution is the same Pre-conditions not necessary for the MCI law
22
22 Other Laws Add before-call Add after-execution returning Merge advices Remove target parameter Remove this parameter
23
23 Conclusions Increase confidence that aspect- oriented programming laws preserve behaviour Equivalence notion for aspect- oriented programs Formal argumentation about the soundness of some laws
24
24 Conclusions Static semantics not considered Formal proof using induction Prove the remaining laws Extend MCI Choose another semantics
25
25 Proving aspect-oriented programming laws Leonardo Cole Paulo Borba Alexandre Mota (lcn,phmb,acm@cin.ufpe.br) Software Productivity Group http://www.cin.ufpe.br/spg Informatics Center Federal University of Pernambuco Brazil
26
26 Comparing Trees
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.