A Calculus of Untyped Aspect-Oriented Programs Paper by Radha Jagadeesan Alan Jeffrey James Riely Presented by Shay Cohen.

Slides:



Advertisements
Similar presentations
1 Classes and Objects in Java Basics of Classes in Java.
Advertisements

User Defined Functions
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Programming Languages and Paradigms
Programming Languages and Paradigms The C Programming Language.
Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
Advice Weaving in AspectJ Paper by Erik Hilsdale Jim Hugunin Presented by Shay Cohen.
Memory Management & Method Calls in Java Program Execution © Allan C. Milne v
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Inheritance and Polymorphism.
An Untyped Calculus of Aspect- Oriented Programs Radha Jagadeesan Alan Jeffrey James Riely DEPAUL UNIVERSITY, CHICAGO.
Runtime Environments Source language issues Storage organization
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
Run-Time Storage Organization
Run time vs. Compile time
AspectJ2EE/Clasa Israel Institute of Technology The Computer Science department Itay Maman.
1 Inheritance and Polymorphism. 2 Motivations Suppose you will define classes to model circles, rectangles, and triangles. These classes have many common.
Unit 061 Java Virtual Machine (JVM) What is Java Virtual Machine? The Class Loader Subsystem Linking oVerification oPreparation oResolution Class Initialization.
Modern Concurrency Abstractions for C# by Nick Benton, Luca Cardelli & C´EDRIC FOURNET Microsoft Research.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
Lecture # 5 Methods and Classes. What is a Method 2 A method is a set of code which is referred to by name and can be called (invoked) at any point in.
The Java Programming Language
Compiler Construction
Chapter 6: User-Defined Functions
Problem Solving using the Java Programming Language May 2010 Mok Heng Ngee Day 5: Arrays.
 2005 Pearson Education, Inc. All rights reserved. 1 Methods Called functions or procedures in other languages Modularize programs by separating its tasks.
1 Classes and Objects in C++ 2 Introduction Java is a true OO language and therefore the underlying structure of all Java programs is classes. Anything.
Constructors CMSC 202. Object Creation Objects are created by using the operator new in statements such as… The following expression invokes a special.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
1 Proving aspect-oriented programming laws Leonardo Cole Paulo Borba Alexandre Mota Informatics Center Federal University of.
Verification of behavioural elements of UML models using B Truong, Ninh-Thuan and Souquieres, Jeanine In Proceedings of the 2005 ACM Symposium on.
Course Progress Lecture 1 –Java data binding: Basket example: UML class diagram -> class dictionary without tokens-> language design -> class dictionary.
Inheritance (Part 5) Odds and ends 1. Static Methods and Inheritance  there is a significant difference between calling a static method and calling a.
COP 2800 Lake Sumter State College Mark Wilson, Instructor.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 9 Inheritance and.
1 Deriving Refactorings for AspectJ Leonardo Cole Paulo Borba Informatics Center Federal University of Pernambuco Brazil.
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
Comparison of Different AOP Approaches Presented by: Xiaojing Wang.
CSC450 Software Engineering Devon M. Simmonds University of North Carolina, Wilmington 1.
AspectScope: An Outline Viewer for AspectJ Programs Michihiro Horie, Shigeru Chiba Tokyo Institute of Technology, Japan.
1 Object-Oriented Programming Inheritance. 2 Superclasses and Subclasses Superclasses and Subclasses  Superclasses and subclasses Object of one class.
Prof. Necula CS 164 Lecture 171 Operational Semantics of Cool ICOM 4029 Lecture 10.
Reference Types CSE301 University of Sunderland Harry R Erwin, PhD.
1 Aspectual Caml an Aspect-Oriented Functional Language Hideaki Tatsuzawa Hidehiko Masuhara Akinori Yonezawa University of Tokyo.
Chapter 9 Introduction to Arrays Fundamentals of Java.
Design issues for Object-Oriented Languages
Paul Ammann & Jeff Offutt
Topic: Classes and Objects
Java Memory Management
Process concept.
Java Memory Management
Java Programming Language
Classes and Objects in Java
Classes and Objects in Java
Classes and Objects in Java
Paul Ammann & Jeff Offutt
UNIT V Run Time Environments.
Dynamic Memory.
Classes and Objects Object Creation
Corresponds with Chapter 5
SPL – PS3 C++ Classes.
CMSC 202 Constructors Version 9/10.
Presentation transcript:

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

Introduction - example Aspects have emerged as a powerful tool For example:

Introduction - intended execution 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 - Example public aspect 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 public class WeavingObject { public static void main(String[] args) { WeavingObject obj = new WeavingObject(); String s = null; obj.go(s); System.out.println(); s = new String("String"); obj.go(s); } public void 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 Reductionism and 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 P has 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 – Syntax (table 1)

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

A Class-based Language – Reduction example

A Class-based Language – Dynamic message (table 2)

A Class-based Language – Value (table 2)

A Class-based Language – Get (table 2)

A Class-based Language – Set (table 2)

A Class-based Language – Return (table 2)

A Class-based Language - Reduction

A Class-based Language – This, Super (table 2)

A Class-based Language – Reduction summary RulesUsage (RC-LET), (RC-RETURN) and (RC- GARBAGE) Deal with pushed frames (RC-VALUE)Returned values to be substituted (RC-DEC) and (RC-HEAP)Create new classes, objects and threads (RC-GET) and (RC-SET)Manipulation of fields (RC-DYN-MSG) and (RC-STC-MSG)Reduction on method calls (LC-THIS)Method body to be retrieved (LC-SUPER)Looks for a method in the superclass

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:

An Aspect-based Language – Aspect based syntax (table 3)

An Aspect-based Language – Semantics of pointcuts (table 4)

Contents Introduction A Class-based Language Syntax Reduction An Aspect-based Language Syntax Reduction Weaving The Correctness of Weaving

An Aspect-based Language – Reduction example

An Aspect-based Language – Dynamic message (table 5)

An Aspect-based Language – Advice message (call) (table 5)

An Aspect-based Language – Advice message (execution) (table 5)

An Aspect-based Language – Reduction

An Aspect-based Language – Aspect based Reduction (table 5)

An Aspect-based Language – Reduction summary RulesPurpose (RA-DYN-MSG) and (RA-STC-MSG)Rely on the advice sets declared by methods. (LA-TOP)Ensure that (RA-DYN-MSG) always succeeds (RA-DYN-MSG)Call and execution advice (RA-ADV-MSG1)Reduction of execution advice. (RA-ADV-MSG2)Reduction of call advice

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 – Close

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.

Weaving – Macro expansion Weaving as Macro Expansion The body of a method is determined by selecting the body of the first advice named in the advice list. The rule is applied again, after substituting the remaining advice through for proceed.

Weaving – New methods Weaving by Introducing New Methods given a method m affected by advice, we create an auxiliary method for each suffix of the list. Call advised methods are placed in the class of the caller, whereas execution advised methods are placed in the class of the callee.

Weaving – Advice weaving (table 6)

Weaving – Advice weaving, execution, call (table 6, 7)

Contents Introduction A Class-based Language Syntax Reduction An Aspect-based Language Syntax Reduction Weaving The Correctness of Weaving

The Correctness of Weaving – Weavability Weaving is not correct for all programs. Weaving does not support the dynamic loading of advice Controlling object of all threads must be defined All advised messages m[ ; ] in a thread with controlling object p should arise no dangling references We formalize these intuitions as Weavability.

The Correctness of Weaving – Weavability definition

The Correctness of Weaving – Weavability of stacks (table 8)

The Correctness of Weaving – Lemma

The Correctness of Weaving – Name equivalence

The Correctness of Weaving – Theorem

The end

Table 1

Table 2

Table 3

Table 4

Table 5

Table 6

Table 7

Table 8

Weaving – Advice weaving

Weaving – Example Declarations Reductions

Weaving – Example X is not free Weaving