larissa an aspect oriented language for reactive systems
play

Larissa, an Aspect-Oriented Language for Reactive Systems PhD - PowerPoint PPT Presentation

Larissa, an Aspect-Oriented Language for Reactive Systems PhD Defense David Stauch Verimag/Grenoble INP November 13th, 2007 Jury Roland Groz Shmuel Katz Mario Sdholt Pascal Fradet Florence Maraninchi Karine Altisen 2/36 Introduction


  1. 10/36 Introduction Larissa Formal Analysis Tools Conclusion Crosscutting Concern 2: Compass Mode Compass Vector model has compass mode select mode/Compass Add Compass mode to Altimax base program mode mode/.. Display mode/... mode/... Time Altimeter Barometer Memory . . . . . . . . .

  2. 10/36 Introduction Larissa Formal Analysis Tools Conclusion Crosscutting Concern 2: Compass Mode Compass Vector model has compass mode select mode/Compass Add Compass mode to Altimax base program mode mode/ Display Compass mode/... mode/... Time Altimeter Barometer Memory . . . . . . . . .

  3. 10/36 Introduction Larissa Formal Analysis Tools Conclusion Crosscutting Concern 2: Compass Mode Compass Vector model has compass mode select mode/Compass Add Compass mode to Altimax base program mode mode/Time mode/ Display Compass mode/... mode/... Time Altimeter Barometer Memory . . . . . . . . .

  4. 11/36 Introduction Larissa Formal Analysis Tools Conclusion Larissa: Aspects for Argos Goal: aspect language for synchronous languages Argos adequate base language simple synchronous language expressive, characterizing constructs Must express cross-cutting concerns Same concepts as other aspect languages: join points, pointcuts, advice

  5. 12/36 Introduction Larissa Formal Analysis Tools Conclusion Outline Introduction 1 Larissa 2 Context and Requirements The Language Example Formal Analysis Tools 3 Conclusion and Further Work 4

  6. 13/36 Introduction Larissa Formal Analysis Tools Conclusion Argos Operators Base elements: boolean signals, complete and deterministic Mealy automata A a a/mod2 A

  7. 13/36 Introduction Larissa Formal Analysis Tools Conclusion Argos Operators Base elements: boolean signals, complete and deterministic Mealy automata Main operators: parallel product, local signals A a a/mod2 B mod2 mod2/mod4 mod2 ( A � B ) \ { mod2 }

  8. 13/36 Introduction Larissa Formal Analysis Tools Conclusion Argos Operators Base elements: boolean signals, complete and deterministic Mealy automata Main operators: parallel product, local signals Semantics: compilation into flat automata A a a a/mod2 a/mod4 a B mod2 a mod2/mod4 mod2 ( A � B ) \ { mod2 }

  9. 14/36 Introduction Larissa Formal Analysis Tools Conclusion Encapsulation Argos programs form expressions, e.g. (( A � B ) \ { a } ) � C A A, B and C automata or a/b Argos expressions a/b B a C

  10. 14/36 Introduction Larissa Formal Analysis Tools Conclusion Encapsulation Argos programs form expressions, e.g. (( A � B ) \ { a } ) � C I A A, B and C automata or a/b Argos expressions a/b Interface: inputs, outputs B a C O

  11. 14/36 Introduction Larissa Formal Analysis Tools Conclusion Encapsulation Argos programs form expressions, e.g. (( A � B ) \ { a } ) � C I A A, B and C automata or a/b Argos expressions a/b Interface: inputs, outputs B a Strong encapsulation: component structure invisible from outside C O

  12. 14/36 Introduction Larissa Formal Analysis Tools Conclusion Encapsulation Argos programs form expressions, e.g. (( A � B ) \ { a } ) � C I A A, B and C automata or a/b Argos expressions a/b Interface: inputs, outputs B a Strong encapsulation: component structure invisible from outside C Operators preserve i/o-trace O equivalence ( ∼ ): if A ′ ∼ A , then (( A ′ � B ) \ { a } ) � C ∼ (( A � B ) \ { a } ) � C

  13. 14/36 Introduction Larissa Formal Analysis Tools Conclusion Encapsulation Argos programs form expressions, e.g. (( A � B ) \ { a } ) � C I A ′ a/b A, B and C automata or Argos expressions Interface: inputs, outputs B a Strong encapsulation: component structure invisible from outside C Operators preserve i/o-trace O equivalence ( ∼ ): if A ′ ∼ A , then (( A ′ � B ) \ { a } ) � C ∼ (( A � B ) \ { a } ) � C

  14. 15/36 Introduction Larissa Formal Analysis Tools Conclusion Requirements: Aspects for Argos Express cross-cutting concerns crosscut structure of Argos expressions parallel composition can express some aspects for sequential languages

  15. 15/36 Introduction Larissa Formal Analysis Tools Conclusion Requirements: Aspects for Argos Express cross-cutting concerns crosscut structure of Argos expressions parallel composition can express some aspects for sequential languages Integrate well into Argos define as translation into automaton simple, formal semantics respect encapsulation, as other Argos operators usually not respected by aspect languages

  16. 16/36 Introduction Larissa Formal Analysis Tools Conclusion Related Work Aspects and Parallelism Concurrent aspects [Douence et al, GPCE06]: asynchronous base program, asynchronous execution of advice

  17. 16/36 Introduction Larissa Formal Analysis Tools Conclusion Related Work Aspects and Parallelism Concurrent aspects [Douence et al, GPCE06]: asynchronous base program, asynchronous execution of advice Formal Properties Many formalisations of aspect languages Aspects preserving the encapsulation: Composition Filters [Bergmans, Aksit]: intercept and modify messages between components Open Modules [Aldrich, ECOOP06]: add additional information to interface

  18. 17/36 Introduction Larissa Formal Analysis Tools Conclusion Larissa Join points: one step in the execution I.e., transitions in an automaton

  19. 17/36 Introduction Larissa Formal Analysis Tools Conclusion Larissa Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Aspect

  20. 17/36 Introduction Larissa Formal Analysis Tools Conclusion Larissa Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions change target state and outputs Aspect

  21. 17/36 Introduction Larissa Formal Analysis Tools Conclusion Larissa Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions change target state and outputs Aspect

  22. 17/36 Introduction Larissa Formal Analysis Tools Conclusion Larissa I Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions O change target state and outputs Challenge: respect encapsulation Aspect

  23. 17/36 Introduction Larissa Formal Analysis Tools Conclusion Larissa I Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions O change target state and outputs Challenge: respect encapsulation Aspect

  24. 17/36 Introduction Larissa Formal Analysis Tools Conclusion Larissa I Join points: one step in the execution I.e., transitions in an automaton Pointcut: select transitions in automaton Advice: modify transitions O change target state and outputs Challenge: respect encapsulation Aspect aspect must only refer to interface

  25. 18/36 Introduction Larissa Formal Analysis Tools Conclusion Pointcuts I Must select transitions a b b O

  26. 18/36 Introduction Larissa Formal Analysis Tools Conclusion Pointcuts I Must select transitions a Solution: observer automaton b inputs: inputs and outputs b of observed program one output JP O Pointcut a b/JP

  27. 18/36 Introduction Larissa Formal Analysis Tools Conclusion Pointcuts I Must select transitions a Solution: observer automaton b inputs: inputs and outputs b of observed program one output JP O Pointcut emits JP Pointcut ⇒ transition in program selected a b/JP

  28. 18/36 Introduction Larissa Formal Analysis Tools Conclusion Pointcuts I Must select transitions a Solution: observer automaton b inputs: inputs and outputs b of observed program one output JP O Pointcut emits JP Pointcut ⇒ transition in program selected a b/JP JP

  29. 18/36 Introduction Larissa Formal Analysis Tools Conclusion Pointcuts I Must select transitions a Solution: observer automaton b inputs: inputs and outputs b of observed program one output JP O Pointcut emits JP Pointcut ⇒ transition in program selected a Transitions identified statically b/JP by parallel product JP

  30. 19/36 Introduction Larissa Formal Analysis Tools Conclusion Advice Difficulty: specify one new target state I O Aspect

  31. 19/36 Introduction Larissa Formal Analysis Tools Conclusion Advice Difficulty: specify one new target state trace a. b I Solution: execute finite input trace automaton deterministic, thus a always identifies one state b b O Aspect

  32. 19/36 Introduction Larissa Formal Analysis Tools Conclusion Advice Difficulty: specify one new target state trace a. b I Solution: execute finite input trace automaton deterministic, thus a always identifies one state b b O Aspect

  33. 19/36 Introduction Larissa Formal Analysis Tools Conclusion Advice Difficulty: specify one new target state trace a. b I Solution: execute finite input trace automaton deterministic, thus a always identifies one state b b O Aspect

  34. 19/36 Introduction Larissa Formal Analysis Tools Conclusion Advice Difficulty: specify one new target state trace a. b I Solution: execute finite input trace automaton deterministic, thus a always identifies one state b b O Aspect

  35. 19/36 Introduction Larissa Formal Analysis Tools Conclusion Advice Difficulty: specify one new target state trace a. b I Solution: execute finite input trace automaton deterministic, thus a always identifies one state b Two kinds: b toInit advice: execute trace from initial state O toCurrent advice: execute trace from source state of transition Aspect

  36. 20/36 Introduction Larissa Formal Analysis Tools Conclusion Example: Logbook Shortcut Aspect LB Pointcut: transitions in main modes where minus is true Advice: trace mode.select.mode.mode, output Logbook mode/ Time mode/ mode/ Alti Baro Time Altimeter Barometer select select select Baro mode mode/ Time mode Alti mode/ mode/ mode mode mode Memory Logbook altimax

  37. 20/36 Introduction Larissa Formal Analysis Tools Conclusion Example: Logbook Shortcut Aspect LB Pointcut: transitions in main modes where minus is true Advice: trace mode.select.mode.mode, output Logbook minus ∧ mode/ JP ,Time mode/ Time .../ JP .../ JP mode/ mode/ .../ JP Alti Baro Time Altimeter Barometer minus/ JP .../ JP .../ JP select select select main .../ JP Time ∨ select Alti ∨ Baro mode mode/ Time mode Baro Alti sub mode/ mode/ mode mode mode pointcut of LB Memory Logbook altimax

  38. 20/36 Introduction Larissa Formal Analysis Tools Conclusion Example: Logbook Shortcut Aspect LB Pointcut: transitions in main modes where minus is true Advice: trace mode.select.mode.mode, output Logbook minus ∧ mode/ JP ,Time mode/ Time .../ JP .../ JP mode/ .../ JP Baro mode Time Altimeter Barometer minus/ JP .../ JP .../ JP select select select main .../ JP Time ∨ select Alti ∨ Baro mode mode/ Time mode Baro Alti sub mode/ mode/ mode mode mode pointcut of LB Memory Logbook altimax

  39. 20/36 Introduction Larissa Formal Analysis Tools Conclusion Example: Logbook Shortcut Aspect LB Pointcut: transitions in main modes where minus is true Advice: trace mode.select.mode.mode, output Logbook mode/ Time mode/ Baro mode Time Altimeter Barometer minus/ JP select select select main Time ∨ select minus/Logbook Alti ∨ minus/Logbook Baro mode mode/ Time mode Baro Alti sub mode/ mode/ mode mode mode pointcut of LB Memory Logbook altimax ⊳ LB

  40. 21/36 Introduction Larissa Formal Analysis Tools Conclusion Advice Program mode Compass Advice insufficient for Compass Concern select mode/ mainMode Replace transition by advice program mode Advice program has terminating state: represents return to base program advice program mode/.. mode/... mode/... Time Altimeter Barometer . . . . . . . . .

  41. 21/36 Introduction Larissa Formal Analysis Tools Conclusion Advice Program mode Compass Advice insufficient for Compass Concern select mode/ mainMode Replace transition by advice program mode Advice program has terminating state: represents return to base program advice program mode/.. mode/... mode/... mode/... Time Altimeter Barometer Compass . . . . . . . . . . . . altimax ⊳ compass

  42. 22/36 Introduction Larissa Formal Analysis Tools Conclusion Recovery Advice and Compiler Recovery advice “Jumping backward” Identify set of recovery states Jump to last recovery state that was passed

  43. 22/36 Introduction Larissa Formal Analysis Tools Conclusion Recovery Advice and Compiler Recovery advice “Jumping backward” Identify set of recovery states Jump to last recovery state that was passed Compiler for Argos and Larissa All language variants implemented Experimentation with many examples Written in Java, AspectJ, BDD library Available at http://www-verimag.imag.fr/ ∼ stauch/ArgosCompiler/

  44. 23/36 Introduction Larissa Formal Analysis Tools Conclusion Outline Introduction 1 Larissa 2 3 Formal Analysis Tools Aspect Interference Aspects and Contracts Conclusion and Further Work 4

  45. 24/36 Introduction Larissa Formal Analysis Tools Conclusion Formal Analysis Tools Larissa: small language, formally defined, with simple semantics Well adapted to study formal properties of aspect languages We studied two such properties: interaction of several aspects combination of Larissa with contracts

  46. 25/36 Introduction Larissa Formal Analysis Tools Conclusion Aspect Interaction Aspect Interaction Do several aspects influence each other? When is P ⊳ A1 ⊳ A2 ∼ P ⊳ A2 ⊳ A1?

  47. 25/36 Introduction Larissa Formal Analysis Tools Conclusion Aspect Interaction Aspect Interaction plus/ JP m Do several aspects influence each other? When is P ⊳ A1 ⊳ A2 ∼ P ⊳ A2 ⊳ A1? main Time ∨ Example: Second Shortcut Aspect M select Alti ∨ Baro Also use plus button as shortcut sub in the main modes Pressing plus goes to the Memory mode Pointcut of M

  48. 26/36 Introduction Larissa Formal Analysis Tools Conclusion Weaving the Second Shortcut Aspect Weave M into altimax ⊳ LB plus/ JP m mode/ Alti Time ... main minus/... Time ∨ select Alti ∨ ... Baro Logbook sub altimax ⊳ LB Pointcut of M

  49. 26/36 Introduction Larissa Formal Analysis Tools Conclusion Weaving the Second Shortcut Aspect Weave M into altimax ⊳ LB When pressing minus in main mode: altimax ⊳ LB goes to submode pointcut stays in main mode plus/ JP m mode/ Alti Time ... main minus/... Time ∨ select Alti ∨ ... Baro Logbook sub altimax ⊳ LB Pointcut of M

  50. 26/36 Introduction Larissa Formal Analysis Tools Conclusion Weaving the Second Shortcut Aspect Weave M into altimax ⊳ LB When pressing minus in main mode: altimax ⊳ LB goes to submode pointcut stays in main mode plus/ JP m mode/ Alti Time ... main minus/... Time ∨ select Alti ∨ ... Baro Logbook sub altimax ⊳ LB Pointcut of M

  51. 26/36 Introduction Larissa Formal Analysis Tools Conclusion Weaving the Second Shortcut Aspect Weave M into altimax ⊳ LB When pressing minus in main mode: altimax ⊳ LB goes to submode pointcut stays in main mode Error: Advice transitions added to Logbook mode plus/ JP m mode/ Alti Time ... main plus/Memory minus/... Time ∨ select Alti ∨ ... Baro Logbook sub altimax ⊳ LB ⊳ M Pointcut of M

  52. 27/36 Introduction Larissa Formal Analysis Tools Conclusion Joint Weaving Problem: aspect M written for altimax, not for altimax ⊳ LB Idea: weave aspects jointly into the program

  53. 27/36 Introduction Larissa Formal Analysis Tools Conclusion Joint Weaving Problem: aspect M written for altimax, not for altimax ⊳ LB Idea: weave aspects jointly into the program Select join points for all aspects first, then apply advice Joint Weaving: altimax ⊳ (LB,M) apply pointcuts and determine join point transitions 1 sequentially apply advice 2

  54. 28/36 Introduction Larissa Formal Analysis Tools Conclusion Application to the Example: altimax ⊳ (LB,M) mode/ Time mode/ mode/ Alti Baro Time Altimeter Barometer select select select mode/ Baro mode mode/ Time mode mode/Alti mode mode mode Memory Logbook

  55. 28/36 Introduction Larissa Formal Analysis Tools Conclusion Application to the Example: altimax ⊳ (LB,M) mode/ Time minus ∧ mode/ JP ,Time .../ JP mode/ .../ JP mode/ .../ JP m .../ JP Alti Baro Time Altimeter Barometer .../ JP .../ JP .../ JP m select .../ JP m select select .../ JP mode/ Baro mode mode/ Time mode mode/Alti mode mode mode Memory Logbook

  56. 28/36 Introduction Larissa Formal Analysis Tools Conclusion Application to the Example: altimax ⊳ (LB,M) mode/ Time minus ∧ mode/ JP ,Time .../ JP mode/ .../ JP mode/ .../ JP Alti Baro Time Altimeter Barometer .../ JP .../ JP select select select .../ JP mode/ Baro mode mode/ Time plus/Memory mode mode/Alti mode mode mode Memory Logbook plus/Memory

  57. 28/36 Introduction Larissa Formal Analysis Tools Conclusion Application to the Example: altimax ⊳ (LB,M) mode/ Time mode/ mode/ Alti Baro Time Altimeter Barometer select select select minus/Logbook minus/Logbook mode/ Baro mode mode/ Time plus/Memory mode mode/Alti mode mode mode Memory Logbook plus/Memory

  58. 29/36 Introduction Larissa Formal Analysis Tools Conclusion Proving Non-Interference Is altimax ⊳ (LB,M) ∼ altimax ⊳ (M,LB)?

  59. 29/36 Introduction Larissa Formal Analysis Tools Conclusion Proving Non-Interference Is altimax ⊳ (LB,M) ∼ altimax ⊳ (M,LB)? Not always, because advice is still applied sequentially Jointly woven Larissa aspects still interfere, if they select the same join point transitions

  60. 29/36 Introduction Larissa Formal Analysis Tools Conclusion Proving Non-Interference Is altimax ⊳ (LB,M) ∼ altimax ⊳ (M,LB)? Not always, because advice is still applied sequentially Jointly woven Larissa aspects still interfere, if they select the same join point transitions Theorem for Jointly-Woven Aspects Noninterference of two aspects, for any base program: if no transition selected by both aspects in product of pointcuts

  61. 29/36 Introduction Larissa Formal Analysis Tools Conclusion Proving Non-Interference Is altimax ⊳ (LB,M) ∼ altimax ⊳ (M,LB)? Not always, because advice is still applied sequentially Jointly woven Larissa aspects still interfere, if they select the same join point transitions Theorem for Jointly-Woven Aspects Noninterference of two aspects, for any base program: if no transition selected by both aspects in product of pointcuts Noninterference of two aspects, for given base program P: if no transition selected by both aspects in product of pointcuts and P

  62. 30/36 Introduction Larissa Formal Analysis Tools Conclusion Design-by-Contract Originally introduced by Bertrand Meyer for object-oriented programming Contract: assumption A ⇒ guarantee G

  63. 30/36 Introduction Larissa Formal Analysis Tools Conclusion Design-by-Contract Originally introduced by Bertrand Meyer for object-oriented programming Contract: assumption A ⇒ guarantee G Example (in Java): class C{ / ∗ @ assume i < 10 ∗ / / ∗ @ guarantee \ result < 10 ∗ / int m(int i ) { . . . } }

  64. 31/36 Introduction Larissa Formal Analysis Tools Conclusion Aspects Modify Contracts Example call to m: i=9, returns 9 i<10 m(9) 9 result<10

  65. 31/36 Introduction Larissa Formal Analysis Tools Conclusion Aspects Modify Contracts Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ i<10 m(9) return 1 + proceed(i + 1); } 9 result<10

  66. 31/36 Introduction Larissa Formal Analysis Tools Conclusion Aspects Modify Contracts Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ i<10 m(9) return 1 + proceed(i + 1); } 9 result<10

  67. 31/36 Introduction Larissa Formal Analysis Tools Conclusion Aspects Modify Contracts Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ i<10 m(9) m(10) return 1 + proceed( i + 1 ); } Now: A violated 9 result<10

  68. 31/36 Introduction Larissa Formal Analysis Tools Conclusion Aspects Modify Contracts Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ i<10 m(9) m(10) return 1 + proceed(i + 1); } Now: A violated, G violated 9 10 result<10

  69. 31/36 Introduction Larissa Formal Analysis Tools Conclusion Aspects Modify Contracts Example call to m: i=9, returns 9 Adding aspect to m: int around(int i): m(i){ i<10 m(9) m(10) return 1 + proceed(i + 1); } Now: A violated, G violated In this case, a new contract for method with aspect can be derived: 9 / ∗ @ assume i < 10 ∗ / 10 result<10 / ∗ @ guarantee \ result < 10 ∗ /

  70. 31/36 Introduction Larissa Formal Analysis Tools Conclusion Aspects Modify Contracts Example call to m: i=9, returns 9 Adding aspect to m: i<9 int around(int i): m(i){ i<10 m(8) m(9) return 1 + proceed(i + 1); } Now: A violated, G violated In this case, a new contract for method with aspect can be derived: 9 / ∗ @ assume i < 9 ∗ / 10 result<10 / ∗ @ guarantee \ result < 10 ∗ /

  71. 31/36 Introduction Larissa Formal Analysis Tools Conclusion Aspects Modify Contracts Example call to m: i=9, returns 9 Adding aspect to m: i<9 int around(int i): m(i){ i<10 m(8) m(9) return 1 + proceed(i + 1); } Now: A violated, G violated In this case, a new contract for method with aspect can be derived: 9 / ∗ @ assume i < 9 ∗ / 10 result<10 / ∗ @ guarantee \ result < 11 ∗ / result<11

  72. 31/36 Introduction Larissa Formal Analysis Tools Conclusion Aspects Modify Contracts Example call to m: i=9, returns 9 Adding aspect to m: i<9 int around(int i): m(i){ i<10 m(8) m(9) return 1 + proceed(i + 1); } Now: A violated, G violated In this case, a new contract for method with aspect can be derived: 9 / ∗ @ assume i < 9 ∗ / 10 result<10 / ∗ @ guarantee \ result < 11 ∗ / result<11 Idea: derive new contracts automatically

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend