SCoPE: an AspectJ Compiler for Supporting User-Defined Analysis-Based Pointcuts Tomoyuki Aotani Hidehiko Masuhara

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
Advertisements

AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
1 Mooly Sagiv and Greta Yorsh School of Computer Science Tel-Aviv University Modern Compiler Design.
Compilation 2007 Code Generation Michael I. Schwartzbach BRICS, University of Aarhus.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
CSE 341, Winter Type Systems Terms to learn about types: –Type –Type system –Statically typed language –Dynamically typed language –Type error –Strongly.
Dept. of Computer Science A Runtime Assertion Checker for the Java Modeling Language (JML) Yoonsik Cheon and Gary T. Leavens SERP 2002, June 24-27, 2002.
Basic Elements of Programming A VB program is built from statements, statements from expressions, expressions from operators and operands, and operands.
Repetition Statements repeat block of code until a condition is satisfied also called loops Java supports 3 kinds of loops: while statement – repeats a.
Runtime Aspect Weaving Through Metaprogramming Jason Baker and Wilson Hsieh Handi-Wrap.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Regression Test Selection for AspectJ Software Guoqing Xu and Atanas.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
Compilation 2007 Scopes and Environments Michael I. Schwartzbach BRICS, University of Aarhus.
Building An Interpreter After having done all of the analysis, it’s possible to run the program directly rather than compile it … and it may be worth it.
TODAY’S LECTURE Review Chapter 2 Go over exercises.
CS 1110 Final Exam: Review Session 2 Part 1 : Inheriting classes 1. Inheritance Facts 2. Constructors in Subclasses BREAK : 10 sec. Part 2 : Working with.
Symbol Table (  ) Contents Map identifiers to the symbol with relevant information about the identifier All information is derived from syntax tree -
XFindBugs: eXtended FindBugs for AspectJ Haihao Shen, Sai Zhang, Jianjun Zhao, Jianhong Fang, Shiyuan Yao Software Theory and Practice Group (STAP) Shanghai.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
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.
1 Specialization Tools and Techniques for Systematic Optimization of System Software McNamee, Walpole, Pu, Cowan, Krasic, Goel, Wagle, Consel, Muller,
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
A Theory of Hygienic Macros David Herman, Mitchell Wand Northeastern University.
A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
Virtual Support for Dynamic Join Points C. Bockisch, M. Haupt, M. Mezini, K. Ostermann Presented by Itai Sharon
Loops (cont.). Loop Statements  while statement  do statement  for statement while ( condition ) statement; do { statement list; } while ( condition.
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.
Aspect-Oriented Action Semantics Descriptions Luis Menezes University of Pernambuco
CS536 Semantic Analysis Introduction with Emphasis on Name Analysis 1.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
Course Progress Lecture 1 –Java data binding: Basket example: UML class diagram -> class dictionary without tokens-> language design -> class dictionary.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Programming Languages
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Java for C++ Programmers A Brief Tutorial. Overview Classes and Objects Simple Program Constructors Arrays Strings Inheritance and Interfaces Exceptions.
Extending the Field Access Pointcuts of AspectJ to Arrays ICS 2006 – Taipei, December 2006 Kung Chen and Chin-Hung Chien* National Chengchi University.
An Advanced Code Pattern: Inner Classes CSE301 University of Sunderland Harry R. Erwin, PhD Half Lecture.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
CSCE 314 Programming Languages Reflection Dr. Hyunyoung Lee 1.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
Comparison of Different AOP Approaches Presented by: Xiaojing Wang.
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
StrongRelaxAJ: integrating adaptability of RelaxAJ and expressiveness of StrongAspectJ Tomoyuki Aotani Manabu Touyama and Hidehiko Masuhara University.
Scheme in Scheme 2. What’s next  Adding set!  Dynamic vs. lexical variable scope  Extending mcscheme v1 with libraries  Can mcscheme execute mcscheme?
Language Implementation Overview John Keyser Spring 2016.
Prof. Necula CS 164 Lecture 171 Operational Semantics of Cool ICOM 4029 Lecture 10.
CSE 501N Fall ’09 07: Iteration 17 September 2009 Nick Leidenfrost.
1 Aspectual Caml an Aspect-Oriented Functional Language Hideaki Tatsuzawa Hidehiko Masuhara Akinori Yonezawa University of Tokyo.
Expressions and Data Types Professor Robin Burke.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
Type Checking and Type Inference
Loops in Java.
Java Primer 1: Types, Classes and Operators
Aspect-Oriented Programming
AspectJ Syntax Basics.
The Boolean (logical) data type boolean
JAsCo an Aspect-Oriented approach tailored for
Presentation transcript:

SCoPE: an AspectJ Compiler for Supporting User-Defined Analysis-Based Pointcuts Tomoyuki Aotani Hidehiko Masuhara

Motivation  Fragile aspects Pointcuts are using immediate properties (method signatures). A small modification to the program could require changes in pointcuts.

Motivation  Analysis-based pointcuts Pointcuts use properties obtained from static program analyses. Stable against program evolution.

Analysis-Based Pointcuts  Class structure analysis Pointcuts match join points based on class structural properties. E.g. insert code at execution of constructor of classes that have a field foo of type Foo: Class Bar_1 { Foo foo; public Bar_1() { … //insert new code here }

Analysis-Based Pointcuts  AspectJ Pointcut contain a list of classes that have field foo. (Object Bar_1 to Bar_n have field foo) pointcut initObjectWithFooField() : execution(Bar_1.new(..)) ||... execution(Bar_n.new(..)); after() returning() : initObjectWithFooField() { //insert code }

SCoPE (Static Conditional Pointcut Evaluation)  A compilation scheme Evaluate analysis-based pointcut at compile time  Using properties from static program analyses  Efficiency – no runtime overhead User-defined pointcut  Wide-range of program analyses Use existing conditional pointcut (if) syntax  No syntactic extensions

Analysis-Based Pointcuts  SCoPE pointcut initObjectWithFooField() : execution(*.new(..)) && if(hasfield(thisJoinPoint, “foo”); static boolean hasfield(JoinPoint tjp, String fname) { try { tjp.getSignature().getDeclaringType().getField(fname); return true; } catch (Exception e) { return false; } }

Conditional Pointcut (if)  AspectJ Compiler Compile conditional pointcut into runtime test  SCoPE Compiler Need to separate dynamic and static conditional pointcut

Definition of Static Conditional Pointcuts  A conditional pointcut is static if its expression always returns the same value with respect to the same join point shadow.

Definition of Static Conditional Pointcuts  if(e) is static if: e is a immutable class variable final static boolean flag = true; pointcut isActive() : if(flag); e does not have a variable bound by other pointcuts. pointcut nullArgument(Object x) : args(x) && if(x == null);

Definition of Static Conditional Pointcuts  if(e) is static if: e is not an invocation of a dynamic method final static Map map = new HashMap(); pointcut mapMethod() : if(map.get(…).boolValue()) e is not an predetermined dynamic method java.lang.Class.newInstance() org.aspectj.lang.JoinPoint.getArgs() etc…

SCoPE Compilation Scheme xxx.javaxxx.aj AspectJ compiler xxx.class Binding-time checker Pointcut evaluator backpatcher xxx.class Weaving information

SCoPE Compilation Scheme Class Bar_1 { Foo foo; public Bar_1() { … } Class Bar_2 { public Bar_2() { … } aspect StructureAnalysis { pointcut initObjectWithFooField() execution(*.new(..)) && if(hasfield(thisJoinPoint, “foo”); static boolean hasfield(JoinPoint tjp, String fname) {...} after() returning() : initObjectWithFooField() {…} }

SCoPE Compilation Scheme  AspectJ compiler Generate weaving information Conditional pointcuts are compiled into if-residues shadow locationif-residue nameparameters 1.5if$1shadow$1 2.4if$1shadow$2

SCoPE Compilation Scheme Class Bar_1 { final static JoinPoint.StaticPart shadow$1 = …; Foo foo; public Bar_1() { … if (StructureAnalysis.if$1(shadow$1)) { StructureAnalysis.aspectOf().after$1(); } Class Bar_2 { final static JoinPoint.StaticPart shadow$2 = …; public Bar_2() { … if (StructureAnalysis.if$1(shadow$2)) { StructureAnalysis.aspectOf().after$1(); }

SCoPE Compilation Scheme class StructureAnalysis { //if-residue //pointcut static boolean if$1(…) { return hasfield(…); } static boolean hasfield(…) {...} //advice void after$1() {…} }

SCoPE Compilation Scheme xxx.javaxxx.aj AspectJ compiler xxx.class Binding-time checker Pointcut evaluator backpatcher xxx.class Weaving information

SCoPE Compilation Scheme  Binding-time checker For each if-residue, decide whether it is static using the definitions.  Pointcut Evaluator Evaluate static if-residues if$1(shadow$1) = true if$1(shadow$2) = false

SCoPE Compilation Scheme  Backpatcher Replace each static if-residue with constant instruction. if(true) //shadow$1 if(false) //shadow$2

SCoPE Compilation Scheme Class Bar_1 { Foo foo; public Bar_1() { … if (true) { //inserted code } Class Bar_2 { public Bar_2() { … if (false) { //inserted code }

Performance  Compared to AspectBench Compiler (abc)  Compilation time Similar speed as abc if pointcut evaluation step is excluded Pointcut evaluation step mainly runs user-defined analysis methods

Performance  Runtime Overheads Split single run into the initialization phase and three consecutive iterations. Measure time spent on each phase. Only 1 st iterations have significant overhead.  Due to conditional branch with a constant value  JVM first executes a program by using a bytecode interpreter.  Will cause overhead until dynamic compiler optimizes it.

Conclusion  Small amount of overhead  User-defined – Flexibility  No additional syntax

Also Fights Gingivitis