towards type safety of aspect oriented languages
play

Towards Type Safety of Aspect-Oriented Languages by Florian - PowerPoint PPT Presentation

Software Engineering Group TU Berlin Towards Type Safety of Aspect-Oriented Languages by Florian Kammller & Matthias Vsgen Outline Introduction Featherweight Java and formalization Formalization of aspects Formalization


  1. Software Engineering Group TU Berlin Towards Type Safety of Aspect-Oriented Languages by Florian Kammüller & Matthias Vösgen

  2. Outline ● Introduction ● Featherweight Java and formalization ● Formalization of aspects ● Formalization of weaving ● AO type soundness ● Future Work F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 2

  3. Theorem provers How do theorem provers work? ● Automatic or human-aided term-rewriting What are the applications? ● Proofs over complex structures (like prog. languages) ● Extraction of verified programs Theorem provers and type-safety Project Bali: Verification of the Java specification using the prover Isabelle. F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 3

  4. Popular theorem provers Isabelle ● Classical logic ● Extensive libraries ● User friendly Coq ● Constructive logic ● Few libraries PVS ACL 2 HOL 4 TWELF (...) F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 4

  5. Why did we choose Coq? Coq is a constructive theorem prover Constructive proofs can be interpreted as algorithms (Curry-Howard Isomorphism) -> Coq can extract code from proofs -> We can extract a typechecker out of a proof for type safety F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 5

  6. Definitions of type soundness Natural language definition: “Well Typed terms never get stuck.” Formal definition: Progress & Preservation Progress: Well-typed terms can be evaluated or they are values. Preservation: The evaluation of a well-typed term leads to a another well-typed term. F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 6

  7. Outline ● Introduction ● Featherweight Java and formalization ● Formalization of aspects ● Formalization of weaving ● AO type soundness ● Future Work F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 7

  8. Featherweight Java Java reduced to: ● Object creation ● Method invocation ● Field access ● Casting ● Variables “Inside every large language is a small language struggling to get out.” F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 8

  9. Properties of Featherweight Java ● Inheritance is part of the language ● Strictly formalized type system ● Very compact ● Quasi-functional language ● Nominal type system ● λ -calculus can be implemented in it F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 9

  10. Featherweight Java example class Pair extends Object { Object fst; Object snd; Pair(Object fst, Object snd) { super(); this.fst = fst; this.snd = snd; } Pair setfst(Object newfst) { return new Pair(newfst, this.snd); } } F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 10

  11. Coq-FJ-Formalization by Stephanie Weirich ● Nearly complete formalization of FJ in Coq ● Type soundness proofs were made ● Clear top-down structure Suitable foundation for extensions F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 11

  12. Type-soundness in FJ Coq-Code for progress and preservation Lemma type_soundness : forall CT: classTable e:expression e':expression, class_table_typing CT // All classes well typed -> multi_step CT e e' // Reduction from e to e' ex. -> ~(exists e'', reduction CT e' e'') // No reduction from e' ex. -> (value e' \/ failed_cast CT e'). // e' is a value or a failed cast F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 12

  13. Outline ● Introduction ● Featherweight Java and formalization ● Formalization of aspects ● Formalization of weaving ● AO type soundness ● Future Work F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 13

  14. Formalization of AO Weaving Class Aspect (...) Advice Pointcut Advice Expression Pointcut Selection F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 14

  15. Aspects Aspect Name {Advice} {Fields} {Methods} Superaspect-Name {Pointcuts} Coq-Code: Inductive aspectDef : Set := | Aspect : aspectName -> aspectName -> list fieldDef -> methodTable ->pointcutTable -> adviceTable -> aspectDef. F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 15

  16. Pointcuts Execution Pointcut {Selections} Name Coq-Code: Inductive pointcutDef: Set := | Execution : pointcutName -> pointcutSelectionList -> pointcutDef. F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 16

  17. Pointcut Selections Pointcut Selection Classname Methodname Coq-Code: Inductive pointcutSelection : Set := | methodSel: className -> methodName -> pointcutSelection. F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 17

  18. Advice Advice Advice expression Pointcutname Coq-Code: Inductive adviceDef: Set := | aroundAdvice: pointcutName -> adviceExp -> adviceDef. F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 18

  19. Advice Expression They are method expressions including a proceed statement Coq-Code: Inductive adviceExp : Set := | proceed: adviceExp | adVar : varName -> adviceExp | adFieldProj : adviceExp -> fieldName -> adviceExp | adMethodInvk : adviceExp -> methodName -> list adviceExp -> adviceExp | adNew : className -> list adviceExp -> adviceExp | adCast : className -> adviceExp -> adviceExp. F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 19

  20. Outline ● Introduction ● Featherweight Java and formalization ● Formalization of aspects ● Formalization of weaving ● AO type soundness ● Future Work F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 20

  21. Weaving, top-level Weaving An aspect-Table is weaved into a class-Table {Aspects} {Classes} Coq-Code: Definition wv_AT_CT (CT: classTable) (AT: aspectTable) : classTable := MapCollect _ _ (fun _ asp => wv_asp_CT CT asp) AT. F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 21

  22. Weaving, bottom level Weaving An advice expression is weaved into a method Advice Method expression Expression Expression Coq-Code: Fixpoint merge_expr (mExpr: exp) (aExpr: adviceExp) {struct aExpr}: exp := match aExpr with proceed => mExpr | adVar v => Var v | adFieldProj aExpr2 fieldN => FieldProj (merge_expr mExpr aExpr2) fieldN (...) end. F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 22

  23. Outline ● Introduction ● Featherweight Java and formalization ● Formalization of aspects ● Formalization of weaving ● AO type soundness ● Future Work F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 23

  24. Type soundness (1) Is an aspect table well typed? Parameter asp_table_typing: aspectTable -> Prop. A well typed aspect table weaves a well typed class table Axiom type_soundness_woven: forall (AT:aspectTable) (CT:classTable), class_table_typing CT -> asp_table_typing AT -> class_table_typing (wv_AT_CT CT AT). F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 24

  25. Type soundness (2) Progress and Preservation with AO: Lemma weave_type_soundness: forall (CT0 CT: classTable)(e e': exp)(AT: aspectTable), CT = wv_AT_CT CT0 AT -> class_table_typing CT0 -> asp_table_typing AT -> multi_step CT e e' -> ~(exists e'', reduction CT e' e'') -> (value e' \/ failed_cast CT e'). F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 25

  26. Outline ● Introduction ● Featherweight Java and formalization ● Formalization of aspects ● Formalization of weaving ● AO type soundness ● Future Work F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 26

  27. Future work There is a lot to do ● Completion of the formalization ● Proof type soundness, confinement etc. ● Investigate the runtime weaving problem F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 27

  28. Thanks for listening! F. Kammüller &M. Vösgen Towards Type Safety of Aspect-Oriented Languages 28

Recommend


More recommend