Extending the Field Access Pointcuts of AspectJ to Arrays ICS 2006 – Taipei, December 2006 Kung Chen and Chin-Hung Chien* National Chengchi University.

Slides:



Advertisements
Similar presentations
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 11 Memory Management C makes it easy to shoot.
Advertisements

Mohamed ElBendary and John Boyland University of Wisconsin-Milwaukee.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
Designing an ADT The design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT What data does.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
Aspect-Oriented Programming In Eclipse ® Aspect-Oriented Programming in Eclipse with AspectJ Dr Helen Hawkins and Sian January.
University of British Columbia Software Practices Lab Fluid AOP Join Point Models Terry Hon Gregor Kiczales.
University of British Columbia Software Practices Lab 2005 CASCON A Fluid AOP Editor Terry Hon Gregor Kiczales.
Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
Aspect Oriented Programming Written by Michael Beder.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University A Framework for Source-Code- Level Interprocedural Dataflow Analysis.
Aspect-Oriented Programming with AspectJ™ AspectJ.org Xerox PARC Erik Hilsdale Gregor Kiczales with Bill Griswold, Jim Hugunin, Wes Isberg, Mik Kersten.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
A Formal Model of Modularity in Aspect-Oriented Programming Jonathan Aldrich : Objects and Aspects Carnegie Mellon University.
XFindBugs: eXtended FindBugs for AspectJ Haihao Shen, Sai Zhang, Jianjun Zhao, Jianhong Fang, Shiyuan Yao Software Theory and Practice Group (STAP) Shanghai.
Outline Introduction Problem Statement Object-Oriented Design Aspect-Oriented Design Conclusion Demo.
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.
Tool support for crosscutting concerns of API documentation Michihiro Horie, Shigeru Chiba Tokyo Institute of Technology, Japan.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
1 A Parameterized Interpreter for Modeling Different AOP Mechanisms Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Genki Moriyama(Kyushu Institute.
Aspect Oriented Programming Gülşah KARADUMAN.
Methodology: The AOP Refactoring Process Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton Advisor:
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.
AspectWrapper CHALFOUN Pierre et BUIST Éric. Overview Introduction – what and why In a nutshell – main components Our approach – how we did it Demo –
Virtual Support for Dynamic Join Points C. Bockisch, M. Haupt, M. Mezini, K. Ostermann Presented by Itai Sharon
Aspect-Oriented Programming and Modular Reasoning G. KiczalesM. Mezini Presented by Alex Berendeyev.
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
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Slicing AspectJ Woven Code Luca Cavallaro Mattia Monga Antonio Castaldo D'Ursi Davide Balzarotti Politecnico di Milano.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
1 Contract-based Verification for Aspect-oriented Refactoring Naoyasu Ubayashi(Kyushu Institute of Technology) Jinji Piao(Kyushu Institute of Technology)
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
Applying Translucid Contracts for Modular Reasoning about Aspect and Object Oriented Events Mehdi Bagherzadeh Gary T. Leavens Robert Dyer Foundations of.
Aspect Oriented Development Alex Beatty.  Purpose  Cross-cutting Concerns  Join Points, Pointcuts, and Advices  Weaving  Invasive vs. Non-Invasive.
Alloy-based Lightweight Verification for Aspect-oriented Architecture Naoyasu Ubayashi(Kyushu Institute of Technology) Yuki Sato(Kyushu Institute of Technology)
AOP-Driven Variability in Software Product Lines Vander Alves, Ayla Dantas, and Paulo Borba Informatics Center – UFPE – Brazil
Aspect Oriented Programming Adlux Consultancy Services Pvt Ltd
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
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.
Applying Aspect-Orientation in Designing Security Systems Shu Gao Florida International University Center for Advanced Distributed Systems Engineering.
StrongRelaxAJ: integrating adaptability of RelaxAJ and expressiveness of StrongAspectJ Tomoyuki Aotani Manabu Touyama and Hidehiko Masuhara University.
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Spring 2012.
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.
SCoPE: an AspectJ Compiler for Supporting User-Defined Analysis-Based Pointcuts Tomoyuki Aotani Hidehiko Masuhara
Why Should You Care About Aspect-Oriented Programming? Karl Lieberherr CCIS.
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
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.
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
An Interface Mechanism for Encapsulating Weaving in Class-based AOP
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Structuring Adaptive Applications using AspectJ and AOM
An Extensible Contract Verifier for AspectJ
Aspect Oriented Programming
Presentation transcript:

Extending the Field Access Pointcuts of AspectJ to Arrays ICS 2006 – Taipei, December 2006 Kung Chen and Chin-Hung Chien* National Chengchi University Hon Hai Precision Industry Co., Ltd*

Agenda Background: Aspect-Oriented Programming (AOP) in AspectJ Motivation Design Considerations Specification of the New Pointcuts Implementation Conclusions

Basic Mechanisms of AOP where Do what aspect Class advice weaving pointcut Aspect Pointcut Advice Weaving Implement Crosscutting concerns modularly

Aspects in AspectJ aspect Name [extends a] { pointcut1; pointcut2; … advice1; advice2; … fields methods } Crosscutting points Actions to take in matched pointcuts Pointcut: selecting a collection of join points

Join Points Model of AspectJ, 1 Join point is a well-defined point in a program’s execution Method call: public void move(int dx, int dy) { setX(_x + dx); setY(_y + dy); } Method call join point:

Join Points Model of AspectJ, 2 Our focus: Field reference and set join points: public void setX(int newx) { x = newx;..println(x); } field set join point: field reference join point:

Agenda Background: Aspect-Oriented Programming (AOP) in AspectJ Motivation Design Considerations Specification of the New Pointcuts Implementation Conclusions

Field Access Join Points of AspectJ Join Points –field reference –field set Pointcut Designators –get(aFieldSignature) –set(aFieldSignature) aspect GuardedX { static final int MAX_CHANGE = 100; before(int newval): set(static int T.x) && args(newval) { if (Math.abs(newval - T.x) > MAX_CHANGE) throw new RuntimeException(); } } Example

Limitations in Using Field Access Pointcuts What if the fields we are interested in are arrays? 01 public class FieldPointcuts { 02 static int ar[]; 03 public static void main( 04 String[] args) { 05 ar = new int[] {100}; //set 06 ar[0] = 200; //get 07 } 08 } set(* *.ar) after() returning (int[] a) : get(* *.ar)

What We Expect Field access pointcuts can also be applied to array elements and further expose information on –the index values of the array element being set or retrieved, and –the value being set to or retrieved from the array element. ar[0] = 200;

Related Work Bruno Harbulot proposed the following arrayset pointcut designator: before(int i, Object s, Object[] a): arrayset() && args(i, s) && target(a) { System.out.println (" Arrayset: ["+i+"/"+(a.length-1)+"] = "+s) ; } The idea is to treat array element set as a call to a “set(int index, object newValue)”

Problems with Harbulot’s Work Ambiguous matching of join points arrayset() && args(i, s) && target(a) arrayset() && args(i1,i2,s) && target(a) ss[0][1] = “two join points”; sss[0][1][2] = “two join points, too”; Mismatch actually two assignments to two 1-D arrays on the byte-code level actually three assignments to three 1-D arrays on the byte-code level Match

Agenda Background: Aspect-Oriented Programming (AOP) in AspectJ Motivation Design Considerations Specification of the New Pointcuts Implementation Conclusions

How We Address This Problem Fix the array target(s) of interest –only need to focus on arrays which are fields of some class –arrays local to a method are irrelevant Include a specification of field signature in our array set/get pointcuts.

Requirements Our arrayset field set pointcut must be flexible enough to select all of them, either individually or as a group. Assignments to a multi-dimensional array can take several forms. 01 class Watch { 02 String [][][] sss= new [2][2][2]; 03 String [][] ss= {{“x”,”y”},{“w”,”z”}}; 04 String [] s= {“abc”, “def”}; 05 sss[0] = ss; 06 sss[0][1] = s; 07 sss[0][1][1] = “change”; 08 ss [0] = s; 09 ss[0][1] = “Me too”; 10 s[0] = ss[1][1]; … }

Agenda Background: Aspect-Oriented Programming (AOP) in AspectJ Motivation Design Considerations Specification of the New Pointcuts Implementation Conclusions

New Field Access Pointcuts Conservative extension of the standard field pointcuts: –arrayset(aFieldSignature) –arrayget(aFieldSignature) Orthogonal to other AspectJ pointcuts – target(), within() and withincode() All array field set join points are treated as having a variable arguments: –the sequence of index values –the value the field is being set to arrayset(* Watch.*) arrayget(* Watch.*)

Context Exposure, 1 Using the args() pointcut aspect Monitor { before(int ix1, int ix2, int newVal): arrayset(* Watch.*) && args(ix1, ix2, newVal) { //advice if (newVal > B.bounds[ix1, ix2]) { ArraySetSignature sig = (ArraySetSignature)tjp.getSignature(); String field = sig.getFieldType() + sig.getName(); throws new RuntimeException("Bad change"+ field) } } 01 class Watch { 02 String [][][] sss= new [2][2][2]; 03 String [][] ss= {{“x”,”y”},{“w”,”z”}}; 04 String [] s= {“abc”, “def”}; 05 sss[0] = ss; 06 sss[0][1] = s; 07 sss[0][1][1] = “change”; 08 ss [0] = s; 09 ss[0][1] = “Me too”; 10 s[0] = ss[1][1]; … } Selective matching – assignments in Line 6 and 9 are captured.

Context Exposure, 2 Can also use the method thisJoinPoint.getArgs() void around() : arrayset( * data.*.* ) { try { ArraySetSignature sig = (ArraySetSignature)tjp.getSignature(); Object[] args = tjp.getArgs(); Integer rhsValue = (Integer)args[args.length-1]; if (rhsValue.intValue() > MAX) { Log.add("Warning: " + sig.getName()); for (int i=0; i<args.length-1; i++) { Log.add("["+ args[i] +"]"); Log.add(" exceeds MAX"); } proceed(); } catch(IndexOutOfBoundException e) {} } Provides great flexibility.

Agenda Background: Aspect-Oriented Programming (AOP) in AspectJ Motivation Design Considerations Specification of the New Pointcuts Implementation Conclusions

Implementation Using the AspectBench Compiler(abc) for AspectJ We follow the standard steps outlined by the abc team to develop this extension. But the following steps are non-trivial: –Identification of join point shadow –Extension of the pointcut matcher of abc

FSM Based Shadow Matcher Cond. #1: instanceOf(getRhs(ca), ArrayFieldRef) Cond. #2: instanceOf(getRhs(ca), ArrayRef) && equalBase(getRhs(ca), ima) && instanceOf (getLhs(ca), Local) Cond. #3: instanceOf(getLhs(ca), ArrayRef) && equalBase(getLhs(ca), ima) Cond. #4: !hasNext() #1: $r2 = r0. #2: $r3 = $r2[0] #3: $r4 = $r3[1] #4: $r5 = new java.lang.String #5: specialinvoke $r5. (java.lang.String)>("foo") #6: $r4[2] = $r5 class C { … Object a[][][] = new Object[2][2][2]; … a[0][1][2] = new String("foo"); … }

Conclusions The field access pointcuts of AspectJ can be extended to expose index-value context for array fields. A FSM-based implementation is presented using the abc compiler for AspectJ. You are welcome to download it and try it yourself.

Q & A