University of Alberta Transactional Pointcuts for Aspect-Oriented Programming by Seyed Hossein Sadat Kooch Mohtasham a Thesis Su

University of Alberta Transactional Pointcuts for Aspect-Oriented Programming by Seyed Hossein Sadat Kooch Mohtasham a Thesis Su

University of Alberta Transactional Pointcuts for Aspect-Oriented Programming by Seyed Hossein Sadat Kooch Mohtasham A thesis submitted to the Faculty of Graduate Studies and Research in partial fulfillment of the requirements for the degree of Doctor of Philosophy Department of Computing Science c Seyed Hossein Sadat Kooch Mohtasham Spring 2011 Edmonton, Alberta Permission is hereby granted to the University of Alberta Libraries to reproduce single copies of this thesis and to lend or sell such copies for private, scholarly or scientific research purposes only. Where the thesis is converted to, or otherwise made available in digital form, the University of Alberta will advise potential users of the thesis of these terms. The author reserves all other publication and other rights in association with the copyright in the thesis and, except as herein before provided, neither the thesis nor any substantial portion thereof may be printed or otherwise reproduced in any material form whatsoever without the author’s prior written permission. Examining Committee H. James Hoover (Advisor), Computing Science Kenny Wong, Computing Science Jos´eNelson Amaral, Computing Science John C. Bowman, Mathematical and Statistical Sciences Gregor Kiczales, Computer Science, University of British Columbia To my wife, and my family, especially Mom and Dad. Abstract In dynamic pointcut-advice join point models of Aspect-Oriented Programming (AOP), join points are typically selected and advised independently of each other. That is, the relationships between join points are not considered in join point selection and advice. But these inter-relationships are key to the designation and advice of arbitrary pieces of code when modularizing concerns such as exception handling and synchronization. Without a mechanism for associating join points, one must instead refactor (if possible) into one method the two or more related join points that are to be advised together. In practice, join points are often not independent. Instead, they form part of a higher-level operation that implements the intent of the developer (e.g. managing a resource). This relationship should be made more explicit. We extend the dynamic pointcut-advice join point model to make possible the desig- nation, reification, and advice of interrelated join points. The Transactional Pointcut (tran- scut), which is a realization of this extended model, is a special join point designator that selects sets of interrelated join points. Each match of a transcut is a set of join points that are related through control flow, dataflow, or both. This allows transcuts to define new types of join points (pieces of computation) by capturing the key points of a computation and to provide effective access for their manipulation (i.e. advice). Essentially, transcuts almost eliminate the need for refactoring to expose join points, which is shown by others to have a significant negative effect on software quality. The transcut construct was implemented as an extension to the AspectJ language and integrated into the AspectBench compiler. We used transcuts to modularize the concern of exception handling in two real-world software systems. The results show that transcuts are effective in designating target join points without unnecessary refactorings, even when the target code is written obliviously to the potential aspectization. Acknowledgements I would like to thank my PhD advisor, H James Hoover, who supported me throughout all the stages of this thesis. His advice, encouragement, and sense of humour enabled me to keep the spirit up and stay focused even at difficult times. Also, I would like to thank my supervisory committee, especially Ken Wong and Jos´e Nelson Amaral, for their invaluable advice and comments during the development of this project. I am also grateful to Gregor Kiczales for his guidance in my early explorations of Aspect-Oriented Programming. Additionally, I would like to show my gratitude to Natural Sciences and Engineering Research Council of Canada for supporting this work. Lastly, I am indebted to all the people who encouraged me and helped me in any way during the completion of this work, especially Daqing Hou and Xin Li for sharing their thoughts and providing feedback on my work. –Hossein Sadat-Mohtasham Table of Contents 1 Introduction 1 1.1 Motivation................................... 2 1.2 Thesis..................................... 3 1.3 Contributions ................................. 3 1.4 Organization.................................. 4 2 Background: Aspect-Oriented Programming 6 2.1 Modularizing Cross-Cutting Concerns . ..... 6 2.2 JoinPointModel ............................... 10 2.3 Pointcut-Advice Dynamic Join Point Model . ..... 10 2.3.1 JoinPoints .............................. 11 2.3.2 Pointcuts ............................... 12 2.3.3 Advice ................................ 14 2.3.4 Aspect Association . 15 2.4 Inter-Type Declarations (Static Cross-Cutting) . ........... 15 2.5 AnExample.................................. 16 3 Transactional Pointcuts 20 3.1 MotivatingExample ............................. 20 3.2 Transactional Pointcuts . 23 3.2.1 NestedTranscuts .. ...... ..... ...... ...... .. 26 3.2.2 Looped and Conditional Pointcuts . 26 3.2.3 Dependent Pointcut . 27 3.2.4 Dataflow Pointcuts and Context Exposure . 29 3.2.5 Overlapping Transcuts . 30 3.3 Program Dependence Graph: the Join Point Representation......... 30 3.3.1 RegionAnalysis ........................... 33 3.3.2 JoinPointShadows. 35 3.3.3 PDG-based Matching Algorithm . 36 3.4 Applications.................................. 40 3.4.1 Modularizing Exception Handling . 42 3.4.2 Transaction Management . 45 3.4.3 Synchronization . 48 3.4.4 Parallelization . 49 3.4.5 Data and Control Context Designation . 50 3.4.6 Static Verification of API Usage . 51 3.5 Implementation ................................ 53 3.6 Limitations .................................. 54 3.6.1 Fragility................................ 54 3.6.2 Interaprocedural Limits, Escaping Objects, and Buried Effects . 55 3.6.3 Continuation vs. History Semantics . 56 4 The Semantics of Transcuts 58 4.1 Continuation-based Semantics for Dynamic Join Points . .......... 58 4.2 Extending the Continuation-based Semantics to Support Transcuts ................................... 62 4.2.1 Defunctionalized CPS Interpreter: a Running Example ....... 63 4.2.2 AOP-Enabled CPS Interpreter . 66 4.2.3 Enabling Transcuts in CPS Interpreter . 68 5 Evaluation 71 5.0.4 Evaluation Strategy . 73 5.0.5 Case Study 1: Tactical Separation Assisted Flight Environment . 75 5.0.6 Case Study 2: Eclipse Instant Messenger Plugin . ..... 80 5.0.7 Weaknesses of Transcuts . 82 5.0.8 SummaryofResults ...... ..... ...... ...... .. 86 6 Related Work 87 7 Conclusions 91 7.1 Contributions ................................. 91 7.2 FutureWork.................................. 92 Bibliography 94 A Construction of the Program Dependence Graph in the Presence of non-Normative Control Flow 98 A.1 Background .................................. 99 A.1.1 ControlFlowGraph ...... ..... ...... ...... .. 99 A.1.2 Dominator and Post-Dominator Trees . 101 A.2 ProgramDependenceGraph . 102 A.2.1 RegionAnalysis . 103 A.2.2 Constructing the Region Hierarchy . 104 A.2.3 Implementation and Usage . 105 A.3 Non-NormativeControlFlow. 106 A.3.1 Abrupt Loop Exit and Continuation . 107 A.3.2 ExceptionalFlow. 107 A.3.3 MultipleExits ............................ 114 A.4 Conclusion ..................................114 List of Tables 2.1 Pointcuts corresponding to various kinds of join points (adapted from [34].) 12 5.1 Four different treatments of exception handling cases in the experiment. 74 5.2 Results of the exception handling modularization in TSAFE system. 75 5.3 Results of the exception handling modularization in EIMP system. 80 List of Figures 2.1 A class from the database layer (left) and the corresponding security aspect (right) ..................................... 7 2.2 Codetanglinginamodule .......................... 9 2.3 Code scattering of security concern . ..... 9 2.4 General form of a named pointcut. 12 2.5 ObserverProtocol aspect (from [24]) . ..... 17 2.6 Observer instance: ColorObserver (from [24]) . ........ 17 2.7 Observer instance: CoordinateObserver (from [24]) . .......... 18 2.8 Observer instance: ScreenObserver (from [24]) . ........ 18 3.1 A simple program that uses the standard Logger class to log messages. 21 3.2 An aspect that guards the log calls and their argument evaluation code . 22 3.3 An example of three different join points: call and execution join points as well as a region join point that could potentially be a match for f(), g() sequence. ................................... 23 3.4 A simple transcut composed of 3 pointcuts. ..... 24 3.5 A transcut that relates the join points based on their target object. 25 3.6 An example of transcut nesting . 26 3.7 Using looped() pointcut in a transcut . 26 3.8 A match for readloop() (left) and a non-match (right). 27 3.9 Using conditional() pointcut in a transcut . 27 3.10 A match for readConditionally() (left) and a non-match (right). 27 3.11 Composition of conditional() and looped() pointcuts. 28 3.12 A match for loopedConditionalRead...................... 28 3.13 An advice that targets a transcut and simply executes the original join point. 28 3.14 Three different matches for the same transcut. ......... 29 3.15 A transcut using dependent() pointcut. .................... 29 3.16 Two overlapping transcuts . 30 3.17 AprogramanditsCFG...........................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    124 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us