Impact Analysis for Aspectj
Total Page:16
File Type:pdf, Size:1020Kb
May 30, 2007 Impact Analysis for AspectJ A Critical Analysis and Tool-Based Approach to AOP Dissertation Maximilian Störzer Eingereicht an der Fakultät für Informatik und Mathematik der Universität Passau Abstract Aspect-Oriented Programming (AOP) has been promoted as a solution for modularization problems known as the tyranny of the dominant decomposition in literature. However, when analyzing AOP languages it can be doubted that uncontrolled AOP is indeed a silver bullet. The contributions of the work presented in this thesis are twofold. First, we critically an- alyze AOP language constructs and their effects on program semantics to sensitize program- mers and researchers to resulting problems. We further demonstrate that AOP—as available in AspectJ and similar languages—can easily result in less understandable, less evolvable, and thus error prone code—quite opposite to its claims. Second, we examine how tools relying on both static and dynamic program analysis can help to detect problematical usage of aspect-oriented constructs. We propose to use change impact analysis techniques to both automatically determine the impact of aspects and to deal with AOP system evolution. We further introduce an analysis technique to detect potential semantical issues related to undefined advice precedence. The thesis concludes with an overview of available open source AspectJ systems and an assessment of aspect-oriented programming considering both fundamentals of software engi- neering and the contents of this thesis. Acknowledgements My thanks goes to Prof. Dr. Gregor Snelting who accepted me as a PhD student and gave me the opportunity to follow my research interests. My thanks also goes to Prof. Dr. Barbara G Ryder (Rutgers University) and Dr. Frank Tip (IBM Research) who gave me the opportunity to participate in their Change Impact Analysis project as a visiting researcher for half a year and who provided funding during this time. I’d also like to thank all students who worked with me and by doing so contributed to this thesis. In alphabetic order, Uli Eibauer, Katrin Fehlner, Andrea Fischer, Florian Forster, Jürgen Graf, Christian Koppen, Christoph Koch, Marc Pfeffer, Michael Pisula, Michael Rank, Stefan Schöffmann, Thorsten Schühlein and, last but not least, Robin Sterr. And of course I’d like to thank my colleague Daniel Wasserrab for his support while writing this thesis. Finally my thanks goes to my parents, who financed my studies of computer science and to Carol, who was my anchor while writing this thesis. Without their support this thesis would not exist. Table of Contents 1 Introduction to AOP 1 1.1 Separation of Concerns . .1 1.1.1 Impact on Programming . .3 1.1.2 Crosscutting Concerns . .4 1.2 The Approach of Aspect-Oriented Programming . .5 1.2.1 Quantification and Obliviousness . .5 1.2.2 An Overview of AspectJ . .6 1.2.3 Aspect-Orientation—An abstract view . .8 1.3 Summary . 11 2 AOP as “Silver Bullet”? 15 2.1 Examining available Case Studies . 15 2.1.1 Aspectizing Distribution . 16 2.1.2 Aspectizing Transactions . 17 2.1.3 Error Handling . 17 2.1.4 Distribution and Persistence . 18 2.1.5 Persistence as an Aspect . 18 2.2 A Critique of AOP . 19 2.2.1 Scalability . 20 2.2.2 Evolvability . 21 2.2.3 Comprehensibility . 21 2.2.4 Reuse . 22 2.2.5 Discussion . 22 2.3 Related Work . 24 2.3.1 Modular Reasoning . 24 2.3.2 Modules in Aspect-Orientation . 26 2.3.3 Summary . 28 3 Static Crosscutting 33 3.1 Background . 33 3.2 Static Crosscutting in AspectJ . 34 3.2.1 Inter Type Declarations . 34 3.2.2 Hierarchy Modifications . 35 3.2.3 Exception Softening . 35 3.2.4 Inter Type Declarations to Interfaces . 36 3.2.5 Running Example . 39 3.3 Theoretical Foundations . 39 3.3.1 The Snelting/Tip Criterion and Statically Bound Members . 40 3.3.2 Extending Snelting/Tip for Fields and Static Methods . 41 3.4 Impact of Default Implementations . 42 3.5 Impact of Class Inter Type Declaration . 44 3.5.1 Field Inter Type Declarations . 44 iv TABLE OF CONTENTS 3.5.2 Overriding Method Inter Type Declarations . 45 3.5.3 Overloading Method Inter Type Declarations . 46 3.5.4 Noninterference Criterion . 47 3.6 Hierarchy Modifications . 49 3.6.1 Hierarchy Change Impact . 49 3.6.2 Hierarchy Modification as Composition . 51 3.6.3 Induced Hierarchy for Static Crosscutting . 51 3.7 Impact of Type Changes . 52 3.8 Finding Changed Lookups . 52 3.8.1 Deriving Lookup Changes . 53 3.8.2 Client Specific versus General Analysis . 58 3.9 An Example Analysis . 59 3.9.1 The System to Analyze . 59 3.9.2 Applying the Proposed Analysis . 59 3.10 Conclusion and Related Work . 62 3.10.1 Summary . 62 3.10.2 Related Work . 63 4 Change Impact Analysis 67 4.1 Basic Concepts of Change Impact Analysis . 67 4.1.1 Challenge of Impact Analysis . 68 4.1.2 Impact Analysis Process . 69 4.1.3 Impact Analysis Algorithms . 70 4.1.4 Change Impact Analysis in Literature . 73 4.1.5 Change Impact Analysis and AspectJ . 75 4.2 The Change Impact Analysis of Chianti . 76 4.2.1 The Change Impact Analysis of Chianti—By Example . 78 4.2.2 Formal Definitions . 81 4.3 Finding Buggy Code using JUnit/CIA . 82 4.3.1 The Scenario . 82 4.3.2 Change Classification—By Example . 84 4.3.3 Test Model and Classification . 85 4.3.4 Change Classification . 85 4.3.5 The JUnit/CIA-Prototype . 87 4.3.6 Effectiveness of Change Classifiers . 90 4.3.7 Related Work . 99 4.3.8 Conclusions and Future Work . 100 4.4 Supporting Early Release of Changes . 101 4.4.1 Early Release of Changes—Why? . 101 4.4.2 Early Release of Changes—By Example . 102 4.4.3 Tests, Changes and Dependences . 105 4.4.4 Detecting Semantic Dependences . 107 4.4.5 Conclusions and Future Work . 113 4.5 CIA for AOP . 113 4.5.1 Analysis Variants and Example . 113 4.5.2 Calculating Changes . 114 4.5.3 Aspects as Change Encodings . 117 4.5.4 Change Impact Analysis for AspectJ . 118 4.5.5 Affected Tests and Affecting Changes . 119 4.5.6 Debugging Support for AOP . 121 4.5.7 Implementation . 122 4.5.8 Evaluation . 124 TABLE OF CONTENTS v 4.5.9 Performance and Scalability . 141 4.5.10 Summary . 143 5 System Evolution 149 5.1 Pointcuts and Coupling . 149 5.1.1 Pointcuts and Aspect-Base Coupling . 150 5.1.2 The Understanding of Pointcuts . 151 5.1.3 Evolution in AO Systems . 152 5.2 Pointcut Delta Analysis . 154 5.2.1 Detecting Failures and their Reasons . 155 5.2.2 Calculating PC-Deltas . 155 5.2.3 Defining an Equality Relation for Pointcuts and Advice . 157 5.2.4 Dynamic Pointcut Designators . 158 5.3 Explaining Deltas . 160 5.3.1 New or Removed Advice . 160 5.3.2 Modified Pointcuts . 161 5.3.3 Base Code Edits . 165 5.3.4 Explained Delta Set . 166 5.3.5 Base Code Edits and Dynamic Predicates . 166 5.4 Case Studies . 166 5.4.1 AspectJ Examples . 167 5.4.2 The abc Test Suite . 171 5.4.3 Auction System . 177 5.4.4 AJHotDraw ............................... 177 5.4.5 HSQLDB ................................. 181 5.4.6 Case Studies—Conclusions . 186 5.5 Related Work . ..