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 as first class entities?
Source semantics is non-trivial. Aspects + OO: redundancy Aspects interfere with OO principles
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
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
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 2
proceed
cbl_d_m cbl_c_m
Name cbl_d_m precedes name cbl_c_m in ordering on advice names
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
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.