Transcript
Page 1: An Untyped Calculus of Aspect-Oriented Programs

An Untyped Calculus of Aspect-Oriented Programs

Radha Jagadeesan

Alan Jeffrey

James Riely

DEPAUL UNIVERSITY, CHICAGO

Page 2: An Untyped Calculus of Aspect-Oriented Programs

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

Page 3: An Untyped Calculus of Aspect-Oriented Programs

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

Page 4: An Untyped Calculus of Aspect-Oriented Programs

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

Page 5: An Untyped Calculus of Aspect-Oriented Programs

AOP languages and OO languages: Folklore

Execution in OO languages is an instance of execution in AOP languages

Aspects interfere with OO principles

Page 6: An Untyped Calculus of Aspect-Oriented Programs

Aspects interfere with OO programming

D1, D2 are distinguishable.

Page 7: An Untyped Calculus of Aspect-Oriented Programs

Aspects as first class entities?

Source semantics is non-trivial. Aspects + OO: redundancy Aspects interfere with OO principles

Page 8: An Untyped Calculus of Aspect-Oriented Programs

Rest of the talk

Overview of results

A sketch of the technical development

Page 9: An Untyped Calculus of Aspect-Oriented Programs

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

Page 10: An Untyped Calculus of Aspect-Oriented Programs

So what?

Dynamic arrival of new advice permitted.

Page 11: An Untyped Calculus of Aspect-Oriented Programs

Specification of weaving

No reductions are lost No new reductions

Page 12: An Untyped Calculus of Aspect-Oriented Programs

Limitations

Limited vocabulary of pointcuts.

Only call/execution join points

Reflection, cflow not included

Global specification of advice order

Page 13: An Untyped Calculus of Aspect-Oriented Programs

Rest of this talk: A sketch of the main ideas

An overview of call vs. execution The aspect calculus Weaving

Page 14: An Untyped Calculus of Aspect-Oriented Programs

An Advised Method call

o:C

u:D

u.foo()a

proceed()

o.foo(u)

Page 15: An Untyped Calculus of Aspect-Oriented Programs

An Advised Method call

o:C

u:D

u.foo()a

proceed()

o.foo(u)

Page 16: An Untyped Calculus of Aspect-Oriented Programs

Call advice

Executed in the controlling context of the caller

Page 17: An Untyped Calculus of Aspect-Oriented Programs

An Advised Method call

o:C

u:D

u.foo()a

proceed()

o.foo(u)

Page 18: An Untyped Calculus of Aspect-Oriented Programs

Execution advice

Executed in the controlling context of the callee

Page 19: An Untyped Calculus of Aspect-Oriented Programs

Rest of this talk

An overview of call vs.. execution The aspect calculus Weaving

Page 20: An Untyped Calculus of Aspect-Oriented Programs

The Aspect Calculus

Class declarations

Pointcuts Advice

Page 21: An Untyped Calculus of Aspect-Oriented Programs

The Aspect Calculus: Classes

Class = list of method names

Methods have no code

Page 22: An Untyped Calculus of Aspect-Oriented Programs

The Aspect Calculus: Pointcuts

Page 23: An Untyped Calculus of Aspect-Oriented Programs

The Aspect Calculus: Advice

Given fixed global ordering on advice names

Page 24: An Untyped Calculus of Aspect-Oriented Programs

Reduction rules: context

Page 25: An Untyped Calculus of Aspect-Oriented Programs

Reduction rules: fetching advice

Keep track of controlling object p{…}

Call advice determined by static type. Execution advice determined by dynamic type

Page 26: An Untyped Calculus of Aspect-Oriented Programs

Reduction rules: call advice

Controlling context of caller p

Substitutions for this, target proceed, parameters

Page 27: An Untyped Calculus of Aspect-Oriented Programs

Reduction rules: execution advice

Controlling context of callee o

Substitutions for this, target proceed, parameters

Page 28: An Untyped Calculus of Aspect-Oriented Programs

Encoding Class Based Language 1

Create an exec advice for each method body

Page 29: An Untyped Calculus of Aspect-Oriented Programs

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

Page 30: An Untyped Calculus of Aspect-Oriented Programs

Rest of this talk

An overview of call vs. execution The aspect calculus Weaving

Page 31: An Untyped Calculus of Aspect-Oriented Programs

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.

Page 32: An Untyped Calculus of Aspect-Oriented Programs

Weaving: Basic idea

View as a kind of macro-expansion.

To weave

Weave recursively

and associate result to the body of method m

Page 33: An Untyped Calculus of Aspect-Oriented Programs

Weaving

Alas. This doesn’t necessarily terminate.

However, postpone macro-expansion to runtime by freezing inside method bodies.

Formalized in paper.

Page 34: An Untyped Calculus of Aspect-Oriented Programs

A subtlety in correctness proof

Weaving of intermediate configurations requires knowledge of controlling object

Page 35: An Untyped Calculus of Aspect-Oriented Programs

Rest of this talk

An overview of call vs. execution The aspect calculus Weaving Summary

Page 36: An Untyped Calculus of Aspect-Oriented Programs

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.

Page 37: An Untyped Calculus of Aspect-Oriented Programs

Moving along

Scale: Larger variety of pointcuts.

Accurate treatment of advice order.

Source level typing


Top Related