370 likes | 502 Views
An Untyped Calculus of Aspect-Oriented Programs. Radha Jagadeesan Alan Jeffrey James Riely DEPAUL UNIVERSITY, CHICAGO. Aspect Oriented Programming. AOSD. Systematic methodology to address cross-cutting concerns A standard example: logging
E N D
An Untyped Calculus of Aspect-Oriented Programs Radha Jagadeesan Alan Jeffrey James Riely DEPAUL UNIVERSITY, CHICAGO
Aspect Oriented Programming • AOSD. Systematic methodology to address cross-cutting concerns • A standard example: logging • AOP. Language support to ``localize’’ cross cutting code • This talk. About AOP languages
Specification via translation Weaving: describe operational semantics of a AOP language via compilation to the underlying paradigm. Aspect + Java ! Java Aspect + Scheme ! Scheme Aspect + ML ! ML Aspect + C ! C
AOP languages and OO languages: Folklore Execution in OO languages is an instance of execution in AOP languages Translation from OO programs P to AOP program Pasp P1! P2, P1asp! P2asp
AOP languages and OO languages: Folklore • Execution in OO languages is an instance of execution in AOP languages • Aspects interfere with OO principles
Aspects interfere with OO programming D1, D2 are distinguishable.
Aspects as first class entities? • Source semantics is non-trivial. • Aspects + OO: redundancy • Aspects interfere with OO principles
Rest of the talk Overview of results A sketch of the technical development
A calculus of AO programs Identify a core set of orthogonal primitives Only AROUND advice No method bodies Only call/execution pointcuts Direct description of the operational semantics of aspect based programs
So what? Dynamic arrival of new advice permitted.
Specification of weaving No reductions are lost No new reductions
Limitations Limited vocabulary of pointcuts. Only call/execution join points Reflection, cflow not included Global specification of advice order
Rest of this talk: A sketch of the main ideas • An overview of call vs. execution • The aspect calculus • Weaving
An Advised Method call u.foo() o:C a proceed() o.foo(u) u:D
An Advised Method call u.foo() o:C a proceed() o.foo(u) u:D
Call advice • Executed in the controlling context of the caller
An Advised Method call u.foo() o:C a proceed() o.foo(u) u:D
Execution advice • Executed in the controlling context of the callee
Rest of this talk • An overview of call vs.. execution • The aspect calculus • Weaving
Class declarations Pointcuts Advice The Aspect Calculus
The Aspect Calculus: Classes Class = list of method names Methods have no code
The Aspect Calculus: Advice Given fixed global ordering on advice names
Reduction rules: fetching advice Keep track of controlling object p{…} Call advice determined by static type. Execution advice determined by dynamic type
Reduction rules: call advice Controlling context of caller p Substitutions for this, target proceed, parameters
Reduction rules: execution advice Controlling context of callee o Substitutions for this, target proceed, parameters
Encoding Class Based Language 1 Create an exec advice for each method body
Encoding Class Based Language 2 Name cbl_d_m precedes name cbl_c_m in ordering on advice names proceed cbl_c_m cbl_d_m
Rest of this talk • An overview of call vs. execution • The aspect calculus • Weaving
Weaving Programs that dynamically load advice affecting existing classes cannot be woven statically. For static advice, weaving algorithm is (by now) standard. Novelty is specification of weaving.
Weaving: Basic idea View as a kind of macro-expansion. To weave Weave recursively and associate result to the body of method m
Weaving Alas. This doesn’t necessarily terminate. However, postpone macro-expansion to runtime by freezing inside method bodies. Formalized in paper.
A subtlety in correctness proof Weaving of intermediate configurations requires knowledge of controlling object
Rest of this talk • An overview of call vs. execution • The aspect calculus • Weaving • Summary
This talk: A calculus of AOP programs Identify a core set of orthogonal primitives Direct description of the execution of programs in an aspect language.
Moving along • Scale: Larger variety of pointcuts. • Accurate treatment of advice order. • Source level typing