710 likes | 720 Views
This paper introduces a calculus for untyped aspect-oriented programs, describing the syntax, reduction rules, and correctness of weaving aspects.
E N D
A Calculus of Untyped Aspect-Oriented Programs Paper by Radha Jagadeesan Alan Jeffrey James Riely Presented by Shay Cohen
Contents • Introduction • A Class-based Language • Syntax • Reduction • An Aspect-based Language • Syntax • Reduction • Weaving • The Correctness of Weaving
Aspects have emerged as a powerful tool For example: Introduction- example
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 Introduction- intended execution
Introduction - Example publicaspect 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); } }
Introduction- Problem publicclass WeavingObject { publicstaticvoid main(String[] args) { WeavingObject obj = new WeavingObject(); String s = null; obj.go(s); System.out.println(); s = new String("String"); obj.go(s); } publicvoid 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
Introduction- Conclusion • Knowing the aspects semantics is essential. • One cannot naively extend object-oriented reasoning to aspect-oriented programs.
Introduction • Reductionismand 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
Contents • Introduction • A Class-based Language • Syntax • Reduction • An Aspect-based Language • Syntax • Reduction • Weaving • The Correctness of Weaving
A Class-based Language - Program • Transformation of a program • A program Phas the form • is a set of declarations • is a set of heap allocated threads and objects.
A Class-based Language – class, thread (table 1) • Superclass d • A set of method declarations • Controlling object p • Stack S
A Class-based Language – object (table 1) • Actual class of the object • Value of fields
A Class-based Language cont. • Method calls may be dispatched • dynamic type • static type
Contents • Introduction • A Class-based Language • Syntax • Reduction • An Aspect-based Language • Syntax • Reduction • Weaving • The Correctness of Weaving
A Class-based Language – Reduction • Reduction proceeds via a standard substitution of parameters
Contents • Introduction • A Class-based Language • Syntax • Reduction • An Aspect-based Language • Syntax • Reduction • Weaving • The Correctness of Weaving
An Aspect-based Language – Example Advised message
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
An Aspect-based Language – Advice (table 3) • Advised method call • Call advice set • Execution advice set • Advice body new command
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
An Aspect-based Language – Advice creation • Given a method definition • methods in the aspect calculus do not have any method bodies:
Questions? Questions? Questions?
Contents • Introduction • A Class-based Language • Syntax • Reduction • An Aspect-based Language • Syntax • Reduction • Weaving • The Correctness of Weaving
An Aspect-based Language – Advice message (execution) (table 5)
An Aspect-based Language – Coherence • advice that appears in a method declaration must be consistent with that which is attached to a pointcut
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.
Contents • Introduction • A Class-based Language • Syntax • Reduction • An Aspect-based Language • Syntax • Reduction • Weaving • The Correctness of Weaving
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.