1 Continuation Join Points Yusuke Endoh, Hidehiko Masuhara, Akinori Yonezawa (University of Tokyo)

Slides:



Advertisements
Similar presentations
The lambda calculus David Walker CS 441. the lambda calculus Originally, the lambda calculus was developed as a logic by Alonzo Church in 1932 –Church.
Advertisements

1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
WEAVING CODE EXTENSIONS INTO JAVASCRIPT Benjamin Lerner, Herman Venter, and Dan Grossman University of Washington, Microsoft Research.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Modularization.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
1 Languages and Compilers (SProg og Oversættere) Sequence control and Subprogram Control.
An Untyped Calculus of Aspect- Oriented Programs Radha Jagadeesan Alan Jeffrey James Riely DEPAUL UNIVERSITY, CHICAGO.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
Survey of Typed Assembly Language (TAL) Introduction and Motivation –Conventional untyped compiler < Typed intermediate languages –Typed intermediate language.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 10 Function Implementation In theory, there.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
Generative Programming. Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing.
Modern Concurrency Abstractions for C# by Nick Benton, Luca Cardelli & C´EDRIC FOURNET Microsoft Research.
2.2 A Simple Syntax-Directed Translator Syntax-Directed Translation 2.4 Parsing 2.5 A Translator for Simple Expressions 2.6 Lexical Analysis.
Imperative Programming
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
Developing Adaptive J2ME Applications Using AspectJ Ayla Débora and Paulo Borba {add, Centro de Informática - UFPE.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
Change Impact Analysis for AspectJ Programs Sai Zhang, Zhongxian Gu, Yu Lin and Jianjun Zhao Shanghai Jiao Tong University.
1 2. Program Construction in Java Programming Fundamentals.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Aspect Oriented Programming Gülşah KARADUMAN.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.
AOSD1 Aspect-Oriented Software Design Karl Lieberherr Theo Skotiniotis.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Virtual Support for Dynamic Join Points C. Bockisch, M. Haupt, M. Mezini, K. Ostermann Presented by Itai Sharon
Semantics. Semantics is a precise definition of the meaning of a syntactically and type-wise correct program. Ideas of meaning: –Operational Semantics.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Region Pointcut for AspectJ Shumpei Akai Shigeru Chiba Muga Nishizawa.
TIVDM2Functional Programming Language Concepts 1 Concepts from Functional Programming Languages Peter Gorm Larsen.
SE424 Languages with Context A Block Structured Language.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Aspect Oriented Development Alex Beatty.  Purpose  Cross-cutting Concerns  Join Points, Pointcuts, and Advices  Weaving  Invasive vs. Non-Invasive.
Towards an Aspect-oriented Language Module: Aspects for Petri Nets Tim Molderez, Bart Meyers, Dirk Janssens and Hans Vangheluwe Ansymo Antwerp Systems.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
Comparison of Different AOP Approaches Presented by: Xiaojing Wang.
aspectj tools new and noteworthy Mik Kersten University of British Columbia Adrian Colyer IBM Hursley OOPSLA, October
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
AspectScope: An Outline Viewer for AspectJ Programs Michihiro Horie, Shigeru Chiba Tokyo Institute of Technology, Japan.
(c) University of Washington10-1 CSC 143 Java Errors and Exceptions Reading: Ch. 15.
1 An AOP Implementation Framework for Extending Join Point Models Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Hidehiko Masuhara(University.
1 Aspectual Caml an Aspect-Oriented Functional Language Hideaki Tatsuzawa Hidehiko Masuhara Akinori Yonezawa University of Tokyo.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 8 Semantic Interpretation To understand a.
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
CS314 – Section 5 Recitation 9
A Simple Syntax-Directed Translator
6.001 SICP Variations on a Scheme
6.001 SICP Compilation Context: special purpose vs. universal machines
Discussion with Gregor Kiczales at UBC
Demeter Aspects Who We Are Aspectual Collaborations
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
Dynamic Scoping Lazy Evaluation
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 12/25/2018.
6.001 SICP Further Variations on a Scheme
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 2/23/2019.
Languages and Compilers (SProg og Oversættere)
Recursive Procedures and Scopes
Presentation transcript:

1 Continuation Join Points Yusuke Endoh, Hidehiko Masuhara, Akinori Yonezawa (University of Tokyo)

2 cmd = readLine(); Main id = readLine(); Login Background: Aspects are reusable in AspectJ (1) Example: A generic logging aspect  can log user inputs in a CUI program  by defining a pointcut logging return value Generic Logging Aspect pointcut input(): call(readLine()) CUI Aspect

3 Background: Aspects are reusable in AspectJ (2) Example: A generic logging aspect  can also log environment variable  by also defining a pointcut Generic Logging Aspect pointcut input(): call(readLine()) CUI Aspect pointcut input(): call(getEnv()) Env Aspect Q. Now, if we want to log environment variable (getEnv) …? A. Merely concretize an aspect additionally Aspect reusability

4 Example: A generic logging aspect  can NOT log inputs in a GUI program by defining a pointcut Problem: Aspects are not as reusable as expected void onSubmit(id) { … } Login void onSubmit(cmd) { … } Main logging arguments Generic Logging Aspect pointcut Input(): call(onSubmit(Str)) GUI Aspect

5 Why can’t we reuse the aspect? Generic Logging Aspect abstract pointcut: input(); after() returning(String s) : input() { Log.add(s); } Logging Aspect (inner) unable to change to before Timing of advice execution depends on both advice modifiers and pointcuts

6 Workaround in AspectJ is awkward: overview Required changes for more reusable aspect:  generic aspect (e.g., logging) two abstract pointcuts, two advice decls. and an auxiliary method  concrete aspects two concrete pointcuts even if they are not needed

7 Workaround in AspectJ is awkward: how to define generic aspect 1. define two pointcuts for before and after 2. define two advice decls. for before and after 3. define auxiliary method abstract pointcut: inputAfter(); abstract pointcut: inputBefore(); after() returning(String s) : inputAfter() { log(s); } before(String s) : inputBefore() && args(s) { log(s); } void log(String s) { Log.add(s); } Simple Logging Aspect

8 Workaround in AspectJ is awkward: how to define concrete aspects Updated Logging Aspect pointcut inputAfter() : call(readLine()); pointcut inputBefore() : never(); CUI Aspect pointcut inputAfter() : never(); pointcut inputBefore() : call(onSubmit(Str)); GUI Aspect always define both pointcuts  even if not needed

9 Summary: Aspect Reusability Problem Aspects are not reusable when advice modifiers need to be changed  CUI/GUI is not an artificial example stand-alone  application framework blocking I/O  non-blocking I/O Workaround is awkward Cause: Timing of advice execution depends on both advice modifiers and pointcuts

10 Contributions The point-in-time join point model PitJ: an experimental AOP language based on the model  completed the language design Pit : simplified version of PitJ based on - calculus  a working interpreter  formalized in CPS

11 Point-in-Time Join Point Model readLine(); readLine(){ } readLine(); readLine(){ } call join point reception join point Define ends of actions as different join points from beginnings of actions region-in-time model (traditional) point-in-time model (proposed) AspectJ, AspectWerkz, JBoss AOP, … call join point

12 PitJ: An Experimental AOP Language Based on Point-in-Time Model is more reusable than AspectJ because of point-in-time model is as expressive as AspectJ base language : Java (AspectJ-like)

13 PitJ: Pointcuts call(method): a call to method reception(method): a return from method failure(method): an exceptional return from method  i.e., exception is thrown by method args(var): binding join point’s value to var  call join point’s value : argument  reception join point’s value : return value  failure join point’s value : exception object

14 PitJ: Examples of Advice (1) No need for advice modifiers  advice(Str s): call(m) && args(s) { … } advices at call join point of the method m in AspectJ: before(): call(m) { … }  advice(Str s): reception(m) && args(s) { … } in AspectJ: after() returning(Str s): call(m) { … }  advice(Obj e): failure(m) && args(e) { … } in AspectJ: after() throwing(Obj e): call(m) { … }

15 PitJ: Examples of Advice (2) before and after advice can be defined in one advice declaration  advice(Str s): (call(onSubmit(Str)) || reception(readLine())) && args(s) { … } runs at both call join point of onSubmit and a reception join point of readLine in AspectJ, corresponding to a pair of advice decls. before(String s): call(onSubmit(Str)) && args(s) { … } after() returning(String s): call(readLine()) { … }

16 Reusable Logging Aspect in PitJ abstract pointcut input(); advice(String s): input() && args(s) { Log.add(s); } Generic Logging Aspect pointcut input(): reception(readLine()) CUI Aspect pointcut input(): call(onSubmit(Str)) GUI Aspect

17 PitJ: Around-like Advice usages of around advice in AspectJ 1. replace the parameters to a join point with new ones 2. replace the return value to the caller of a join point 3. go back to the caller without executing a join point 4. execute a join point more than once In PitJ, these are realized by:  1, 2  return in advice body  3  new construct: skip  4  special function: proceed

18 return in advice body (1) replaces join point’s value Example: at call join point  advice(Str s): call(m) && args(s) { return sanitize(s); } replaces the argument of m with the sanitized one  in AspectJ: around(Str s): call(m) && args(s) { return proceed(sanitize(s)); }

19 return in advice body (2) Example: at reception join point  advice(Str s): reception(m) && args(s) { return sanitize(s); } replaces the return value of m with the sanitized one  in AspectJ: around(Str s): call(m) && args(s) { return sanitize(proceed(s)); }

20 new construct: skip skip is evaluated in a call join point:  skips subsequent advice decls. and the call itself i.e., jumps to the corresponding reception join point in a reception or failure join point:  skips subsequent advice decls. Example:  advice(): call(readLine()) { skip “dummy”; } makes readLine always return “dummy”  in AspectJ: String around(): call(readLine()) { return “dummy”; }

21 special function: proceed proceed is evaluated in a call join point:  executes the action until the corresponding reception join point in a reception or failure join point:  no effect Example:  advice(): call(readLine) { proceed(); } let readLine skip every other line  advice(): call(readLine) { skip(proceed() + proceed()); } let readLine return a concatenation of two lines  advice(): call(readLine) { skip(proceed()); } no effect

22 Summary: PitJ No need for advice modifiers Advice decls. are more reusable than AspectJ’s due to the point-in-time model PitJ is as expressive as AspectJ’s advice mechanism  before : call join points  after : reception or failure join point  around-like : skip and proceed

23 Formalization of Point-in-Time Model target: Pit  simplified version of PitJ  base language: untyped -calculus approach:  denotational semantics in continuation-passing style  key idea: denote join points as applications to continuation

24 Semantic Equations: Advice A : advice list  Event  Ctn  Ctn  Event : kind of join point  Ctn : continuation A [A]   : return continuation that:  selects applicable advice decls. from A (list of advice)  executes them, and  executes  (continuation)  : kind of join point

25 Semantic Equations: Expression E : expression  Ctn  Ans  Ctn : continuation  Ans : answer E [E]  : evaluates E and executes   E : expression   : continuation

26 Sample Program in Pit advice call(f) && args(x)  x+1 advice reception(f) && args(x)  x+2 let f x = x*2 in f 2  8 f 2 let f x = x*

27 E [ E 0 E 1 ]  = E [ E 0 ] ( f. E [ E 1 ] ( v. f  v)) Semantics of Function Call (abridged) semantics of -calculus without aspect mechanism semantics of -calculus with advice mechanism E [ E 0 E 1 ]  = E [ E 0 ] ( f. E [ E 1 ] ( v. (f  ) v)) f  : continuation A [ A ] call (f  ) v  application to continuation = call join point E [ E 0 E 1 ]  = E [ E 0 ] ( f. E [ E 1 ] ( v. A [ A ] call (f  ) v)) E [ E 0 E 1 ]  = E [ E 0 ] ( f. E [ E 1 ] ( v. A [ A ] call (f ( v.  v)) v)) A [ A ] reception application to continuation   v = reception join point f 2 let f x = x*2 we can define it in systematic way!

28 Advantages of Our Formalization simpler than existing formalizations [Wand ’02] [Walker ’03]  no need for rules for each advice modifier  beginnings and ends of actions are represented symmetrically easier to support advanced features  exception handling  context sensitive pointcuts (cflow)  around advice

29 exception handling (sketch) give a standard semantics  by adding continuation that represents current handler identify failure join point E [ E 0 E 1 ]   h = E [ E 0 ] ( f. E [ E 1 ] ( v. A [ A ] call (f ( v. A [ A ] reception   h v) ( v.  h v) )  h v)  h )  h semantics of -calculus without aspect mechanism ( v. A [ A ] failure  h  h v) ) semantics of -calculus with advice mechanism

30 around-like advice (concept) using idea of partial continuation [Danvy ’89]  a part of the rest of computation, rather than the whole rest we currently formalized by using continuation- composing style f 2 let f x = x*2 partial continuation = skip / proceed

31 Related Work approaches based on the region-in-time model:  Aspect SandBox [Wand ’02], Tucker et al. ’03, MiniMAO [Clifton ‘05], some approaches treat beginning and end of an event as different join points, but that have different motivations  Walker et al. ’03: propose a low-level language that serves as a target of translation from a high-level AOP language  Douence et al. ’04: define a formal semantics of cflow by using calling contexts from execution history

32 Conclusion a new join point model that defines beginnings and ends of actions as different join points  Point-in-time vs. Region-in-time  designed PitJ based on the model improves aspect reusability by enhancing expressiveness of pointcuts  formalized the model in continuation-passing style simpler than some existing formalizations easier to support advanced features

33 Future Work integrate more advanced features  dflow pointcut [Kawauchi ’03]  first-class continuation  tail-call elimination implement a compiler for PitJ language  Java bytecode should be made without CPS transformation