Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Calculus of Untyped Aspect-Oriented Programs Paper by Radha Jagadeesan Alan Jeffrey James Riely Presented by Shay Cohen.

Similar presentations


Presentation on theme: "A Calculus of Untyped Aspect-Oriented Programs Paper by Radha Jagadeesan Alan Jeffrey James Riely Presented by Shay Cohen."— Presentation transcript:

1 A Calculus of Untyped Aspect-Oriented Programs Paper by Radha Jagadeesan Alan Jeffrey James Riely Presented by Shay Cohen

2 Contents Introduction A Class-based Language Syntax Reduction An Aspect-based Language Syntax Reduction Weaving The Correctness of Weaving

3 Introduction - example Aspects have emerged as a powerful tool For example:

4 Introduction - intended execution The intended execution semantics is as follows: a call to foo() invokes the code associated with the advice (the timer is started) foo() method is invoked when control reaches proceed() Upon termination of foo(), control returns to the advice

5 Introduction - Example public aspect WeavingAspect { before (String s): execution(void go(*)) && args(s) { System.out.println("before (String s): execution(void go(*)) && args(s) " + s); } before (Object s): execution(void go(*)) && args(s) { System.out.println("before (Object s): execution(void go(*)) && args(s) " + s); }

6 Introduction - Problem public class WeavingObject { public static void main(String[] args) { WeavingObject obj = new WeavingObject(); String s = null; obj.go(s); System.out.println(); s = new String("String"); obj.go(s); } public void go(Object s) { System.out.println("go(Object s) " + s); } before (Object s): execution(void go(*)) && args(s) null go(Object s) null before (String s): execution(void go(*)) && args(s) String before (Object s): execution(void go(*)) && args(s) String go(Object s) String

7 Introduction - Conclusion Knowing the aspects semantics is essential. One cannot naively extend object- oriented reasoning to aspect-oriented programs.

8 Introduction Reductionism and a specification for weaving: Advice looked as a primitive Only around advice No reflection Focusing on dynamics At the end correctness of the weaving transformation will be shown Weavability will be defined to exclude programs that cannot be woven statically

9 Contents Introduction A Class-based Language Syntax Reduction An Aspect-based Language Syntax Reduction Weaving The Correctness of Weaving

10 A Class-based Language - Program Transformation of a program A program P has the form is a set of declarations is a set of heap allocated threads and objects.

11 A Class-based Language – class, thread (table 1)  Superclass d  A set of method declarations  Controlling object p  Stack S

12 A Class-based Language – object (table 1)  Actual class of the object  Value of fields

13 A Class-based Language – Syntax (table 1)

14 A Class-based Language cont. Method calls may be dispatched dynamic type static type

15 Contents Introduction A Class-based Language Syntax Reduction An Aspect-based Language Syntax Reduction Weaving The Correctness of Weaving

16 A Class-based Language – Reduction Reduction proceeds via a standard substitution of parameters

17 A Class-based Language – Reduction example

18 A Class-based Language – Dynamic message (table 2)

19 A Class-based Language – Value (table 2)

20 A Class-based Language – Get (table 2)

21 A Class-based Language – Set (table 2)

22 A Class-based Language – Return (table 2)

23 A Class-based Language - Reduction

24 A Class-based Language – This, Super (table 2)

25 A Class-based Language – Reduction summary RulesUsage (RC-LET), (RC-RETURN) and (RC- GARBAGE) Deal with pushed frames (RC-VALUE)Returned values to be substituted (RC-DEC) and (RC-HEAP)Create new classes, objects and threads (RC-GET) and (RC-SET)Manipulation of fields (RC-DYN-MSG) and (RC-STC-MSG)Reduction on method calls (LC-THIS)Method body to be retrieved (LC-SUPER)Looks for a method in the superclass

26 Contents Introduction A Class-based Language Syntax Reduction An Aspect-based Language Syntax Reduction Weaving The Correctness of Weaving

27 An Aspect-based Language – Example Advised message

28 An Aspect-based Language – Aspect declaration (table 3) Aspect declaration Name – allows reference Command sequence – what to execute Pointcut – when to execute pointcuts are presented as elements of the Boolean algebra

29 An Aspect-based Language – Advice (table 3) Advised method call Call advice set Execution advice set Advice body new command

30 An Aspect-based Language – method (table 3) Dynamically dispatched method changed We now have the static type as well Static type is needed for call advice We ignore call advice for super calls

31 An Aspect-based Language – Advice creation Given a method definition methods in the aspect calculus do not have any method bodies:

32 An Aspect-based Language – Aspect based syntax (table 3)

33 An Aspect-based Language – Semantics of pointcuts (table 4)

34

35

36

37

38 Contents Introduction A Class-based Language Syntax Reduction An Aspect-based Language Syntax Reduction Weaving The Correctness of Weaving

39 An Aspect-based Language – Reduction example

40 An Aspect-based Language – Dynamic message (table 5)

41 An Aspect-based Language – Advice message (call) (table 5)

42 An Aspect-based Language – Advice message (execution) (table 5)

43 An Aspect-based Language – Reduction

44 An Aspect-based Language – Aspect based Reduction (table 5)

45 An Aspect-based Language – Reduction summary RulesPurpose (RA-DYN-MSG) and (RA-STC-MSG)Rely on the advice sets declared by methods. (LA-TOP)Ensure that (RA-DYN-MSG) always succeeds (RA-DYN-MSG)Call and execution advice (RA-ADV-MSG1)Reduction of execution advice. (RA-ADV-MSG2)Reduction of call advice

46 An Aspect-based Language – Coherence advice that appears in a method declaration must be consistent with that which is attached to a pointcut

47 An Aspect-based Language – Close

48 An Aspect-based Language – Lemma Note that any program where each class declaration is taken from the class-based language is semi-coherent by construction.

49 Contents Introduction A Class-based Language Syntax Reduction An Aspect-based Language Syntax Reduction Weaving The Correctness of Weaving

50 Weaving – Requirements Correctness is formalized by demanding that the following diagram can be completed We also expect that a woven program not have spurious new reductions.

51 Weaving – Macro expansion Weaving as Macro Expansion The body of a method is determined by selecting the body of the first advice named in the advice list. The rule is applied again, after substituting the remaining advice through for proceed.

52 Weaving – New methods Weaving by Introducing New Methods given a method m affected by advice, we create an auxiliary method for each suffix of the list. Call advised methods are placed in the class of the caller, whereas execution advised methods are placed in the class of the callee.

53 Weaving – Advice weaving (table 6)

54

55 Weaving – Advice weaving, execution, call (table 6, 7)

56 Contents Introduction A Class-based Language Syntax Reduction An Aspect-based Language Syntax Reduction Weaving The Correctness of Weaving

57 The Correctness of Weaving – Weavability Weaving is not correct for all programs. Weaving does not support the dynamic loading of advice Controlling object of all threads must be defined All advised messages m[ ; ] in a thread with controlling object p should arise no dangling references We formalize these intuitions as Weavability.

58 The Correctness of Weaving – Weavability definition

59 The Correctness of Weaving – Weavability of stacks (table 8)

60 The Correctness of Weaving – Lemma

61 The Correctness of Weaving – Name equivalence

62 The Correctness of Weaving – Theorem

63 The end

64 Table 1

65 Table 2

66 Table 3

67 Table 4

68 Table 5

69 Table 6

70 Table 7

71 Table 8

72 Weaving – Advice weaving

73 Weaving – Example Declarations Reductions

74 Weaving – Example X is not free Weaving


Download ppt "A Calculus of Untyped Aspect-Oriented Programs Paper by Radha Jagadeesan Alan Jeffrey James Riely Presented by Shay Cohen."

Similar presentations


Ads by Google