ENHANCING BASE CODE PROTECTION IN ASPECT ORIENTED PROGRAMS Mohamed - - PowerPoint PPT Presentation

enhancing base code protection in aspect oriented programs
SMART_READER_LITE
LIVE PREVIEW

ENHANCING BASE CODE PROTECTION IN ASPECT ORIENTED PROGRAMS Mohamed - - PowerPoint PPT Presentation

ENHANCING BASE CODE PROTECTION IN ASPECT ORIENTED PROGRAMS Mohamed ElBendary and John Boyland University of Wisconsin Milwaukee Outline Introduction Motivation Our AOP Modularity Focus Interface Image (I2) Approach


slide-1
SLIDE 1

ENHANCING BASE‐CODE PROTECTION IN ASPECT‐ORIENTED PROGRAMS

Mohamed ElBendary and John Boyland

University of Wisconsin‐Milwaukee

slide-2
SLIDE 2

Outline

Introduction ‐ Motivation Our AOP Modularity Focus Interface Image (I2) Approach I2 implementation I2 Evaluation Related Work Conclusion

slide-3
SLIDE 3

Introduction ‐ Motivation

Separation of crosscutting concerns Roadblocks to AOP adoption

Not just education Reality of coding standards for small companies Lack of invasiveness regulation Pure obliviousness

Support for AOP adoption has to come at the

language level.

slide-4
SLIDE 4

Introduction ‐ Motivation

Interfaces Role Overlap:

Base code sees: Service Access Points Aspect code sees: Event Hooks

Protection (invasiveness control) is easier

when roles are separated

slide-5
SLIDE 5

Our AOP Modularity Focus

Independent evolution of components Expanding parallel development Enhancing module protection Supporting modular reasoning

slide-6
SLIDE 6

Classical AOP Limitations

In our context, Classical AOP means: Pure

Obliviousness

Tight coupling between aspects and base code Base code cannot regulate any advising activity on

itself

Impossible to reason about a base code component

solely by examining its interface (Tool support can help with this)

slide-7
SLIDE 7

Interface Image (I2) Approach

What is an Interface Image? “image” construct syntax “image” construct semantics What does I2 offer?

slide-8
SLIDE 8

What is an interface image?

A language mechanism for exporting views of

a component’s advisable interface

A middleware through which all advising is

carried out

A language mechanism for base code to

express advising constraints

slide-9
SLIDE 9

Separation of XCC – I2 Style

Component A

A’s Internals

A’s Interface

A’s Interface Image

Component B

B’s Internals

B’s Interface

B’s Interface Image

Logging Concern

slide-10
SLIDE 10

The “image” construct

image { [opento: {aspects allowed ITD’s}] [alias definitions] }

An empty image scope reduces I2 to AspectJ‐

style AOP

slide-11
SLIDE 11

Alias Definitions ‐ Syntax

[modifiers] RT method-name(P) = [modifiers] RT alias(P) { Constraints } modifiers: Java-style method modifiers RT: return type method-name, alias: Java-style method identifier P: Java-style method parameter list Constraints: A list of advising constraints

slide-12
SLIDE 12

Constraints: kind clause

Kind: {Advice_Kind*} Advice_Kind: before | after| after_returning |

after_throwing | around

slide-13
SLIDE 13

Constraints: (origin, boundary)

(origin=ORIGIN, boundary=BOUNDARY); ORIGIN: internal | external BOUNDARY: method | class | package

slide-14
SLIDE 14

Constraints: exceptions clause

Exceptions: {Exception_Type*} Exception_Type: Java‐style type identifier

slide-15
SLIDE 15

“image” Construct Semantics

Only classes declaring images are advisable Omitting a clause implies no constraint Empty “kind” list implies no advice allowed Empty “exceptions” list implies no checked

exceptions can be softened

slide-16
SLIDE 16

“image” Construct Semantics

“opento” semantics “kind” semantics “(origin, boundary)” semantics “exceptions” semantics

slide-17
SLIDE 17

Alias Definition Rules

A class can only alias methods it declares Multiple (distinct) aliases for the same aliased

method allowed

Alias definitions in a base class are advisable

in derived class unless method private in base

slide-18
SLIDE 18

Example: Point class

Class Point extends Shape { protected int x, y; public void moveby(int dx, int dy){ x += dx; y += dy; } // image goes here (next slide) }

slide-19
SLIDE 19

Example: Point class

Image {

  • pento: {CheckScence};

public void moveby(int dx, int dy) = public void translate(int dx, int dy) { kind: {after}; (origin=external, boundary=class); exceptions: {SceneInvariantViolation}; } }

slide-20
SLIDE 20

Example: Rectangle class

class Rectangle extends Shape { void moveby(int dx, int dy){ p1x += dx; p1y += dy; p2x += dx; p2y += dy; } image { void moveby(int, int) = void translate(int, int){} } }

slide-21
SLIDE 21

Example: CheckSceneInvariants aspect

aspect CheckSceneInvariants { pointcut moves(): call (void Shape+.translate(..)); after(): moves() { scene.checkInvariants(); } }

slide-22
SLIDE 22

Example: modifying moveby()

class Rectangle extends Shape { void moveby(int dx, int dy){ p1x += dx; p1y += dy; p2x += dx; p2y += dy; } image { void moveby(int, int) = void translate(int, int){} } }

P1.moveby(dx,dy); P2.moveby(dx,dy);

slide-23
SLIDE 23

Example: Updating Point

class Point extends Shape { … image { … void moveby(int, int) = void translate(int, int){ (origin=external, boundary=class); } } }

slide-24
SLIDE 24

What does I2 offer?

A level of indirection through which all

advising requests are carried out

Provides base code qualification of classes:

advisable and unadvisable

A mechanism for base code to expose views

  • f joinpoints along with advising constraints
slide-25
SLIDE 25

What does I2 offer?

Control over aspect invasiveness (traded for

less obliviousness)

I2 affords better parallel development and

reduces aspect brittleness

I2 advising control does not limit AOP

capabilities

slide-26
SLIDE 26

I2 Implementation

JastAdd

Error Checking AST Rewrite

abc

Compilation Sequence

slide-27
SLIDE 27

I2 Implementation

Image checking and collecting information:

“opento” clause “kind” clause “exceptions” clause

slide-28
SLIDE 28

I2 Implementation

  • “image” rewrite
  • Wrapper methods introduction
  • (origin, boundary) to pointcuts
  • “around” advice
  • Sample translation
  • Precedence ordering aspect
slide-29
SLIDE 29

Sample Translation

Priviliged static imageAspect { public void Point.translate(int dx, int dy) { moveby(dx, dy); } void around(Point p): target(p) && !within(imageAspect) && !within(Point) && call(public void Point.moveby(int dx, int dy)){ p.translate(dx, dy); } }

slide-30
SLIDE 30

Precedence Ordering Aspect

public aspect _internalOrderingAspect{ declare precedence: *..*imageAspect*. *; }

slide-31
SLIDE 31

Compilation Sequence

Image checking happens after computing intertype

declarations

Image rewrite and precedence ordering aspect Computing advice lists Filtering advice Weaving

slide-32
SLIDE 32

Evaluation: Quantitative

What are we measuring? How are we measuring it? Evaluation examples Results

slide-33
SLIDE 33

What are we measuring?

We measure coupling between aspects and

base code classes

Coupling is measured in terms of crosscutting

relationships

Crosscutting relationships result from advice

and intertype declarations

slide-34
SLIDE 34

How are we measuring it?

Simulating effects of I2 syntax for AJDT Input to AJDT

slide-35
SLIDE 35

Evaluation Examples

Subject/Observer Protocol (1p, 6c, 2a) A Simple Telecom Simulation (1p, 10c, 2 a) Ants Simulation (11p, 33c, 11a)

slide-36
SLIDE 36

Results

I2 induces 26.3% more coupling for

Subject/Observer Protocol

I2 reduces coupling by 20% for Telecom

Simulation

I2 reduces coupling by 6.6% for Ants

Simulation

slide-37
SLIDE 37

Results

Subject/Observer has only one advice, not

much room for decoupling with aliases

The use of “opento” introduces crosscutting

relationships that were not existing in the

  • riginal implementation
slide-38
SLIDE 38

Results

The more aspects use advice, the more the

payoff (more room for aliasing)

Ants Simulation is closer to real AOP

programs in terms of the feature‐mix. So it’s result is a better representative of effects of aliasing

slide-39
SLIDE 39

Related Work

Open Modules(2004) AAI (2005) XPI (2006) EJP (2007) MAO (2007) Ptolemy (2007, 2008, 2009?) Key distinction

slide-40
SLIDE 40

Differences from Open Modules

Loose coupling without restricting advising I2 exposes an explicit set of joinpoints versus

compact OM pointcuts

Flexible joinpoint aliasing and advising

constraints

slide-41
SLIDE 41

Differences from AAI

In I2, class is oblivious to which aspect will be

extending its interface (except with opento)

Improved readability Loose coupling between base code and

aspect code

slide-42
SLIDE 42

Differences from XPI

In I2, joinpoints and constraints are the responsibility

  • f the base code while pointcuts and advice are of

the aspect code

In I2, all advice is channeled through images Documentation of entry points into the class

interface

slide-43
SLIDE 43

Differences from EJP

EJP can advise arbitrary blocks of code, I2

cannot

EJP requires advising markers to be placed

manually in the source code, I2 does not

EJP does not incorporate advising constraints

  • n the base code side
slide-44
SLIDE 44

Differences from MAO

MAO supports better modular reasoning in

exchange for less feature‐obliviousness

Control effects and heap effects I2 engages the base code while MAO engages

the aspect code for protection

slide-45
SLIDE 45

Ptolemy

Solves the fragile pointcut problem using

typed events that pointcuts can be written in terms of

I2 still relies on aliases so pointcuts are as

stable as the aliases

I2 relies on the predefined possible events of

AspectJ

slide-46
SLIDE 46

Key Distinction

I2 recognize that interface specifications (e.g.

method signatures) are intended to play two different roles in one breath:

Service Access Points Joinpoints for use by aspects

I2 reassigns these responsibilities by introducing the

image construct and removes the role overlap

slide-47
SLIDE 47

Conclusion

It is possible to realize a design that loosely

couples the evolution of base code interfaces from the AO code advising those components.

It is possible to afford better parallel

development and maintainability in exchange for less obliviousness.

slide-48
SLIDE 48

Conclusion

It is possible to provide a level of protection

to the base code without restricting AO capabilities.

Aid to modular reasoning in the presence of

aspects.

Achievable while maintaining a practical level

that facilitates AOP adoption.

slide-49
SLIDE 49

Thank You!