Object-Centric Reflection

Object-Centric Reflection

Object-Centric Reflection Unifying Reflection and Bringing It Back to Objects Inauguraldissertation der Philosophisch-naturwissenschaftlichen Fakultät der Universität Bern vorgelegt von Jorge Ressia von Argentina Leiter der Arbeit: Prof. Dr. O. Nierstrasz Institut für Informatik und angewandte Mathematik This dissertation is available as a free download from scg.unibe.ch. Copyright © 2012 Jorge Ressia, www.jorgeressia.com. The contents of this dissertation are protected under Creative Commons Attribution-ShareAlike 3.0 Unported license. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to creativecommons.org/licenses/by-sa/3.0/. The logos of Bifröst and Prisma have been influenced by the design channel abduzeedo.com. ISBN 978-1-291-07262-4 First Edition, October 2012. Acknowledgements First of all I would like to thank Oscar Nierstrasz for giving me the opportunity to work at the Software Composition Group. I thank him for his advice and guidance and specially for pushing me to go beyond my limitations. I am grateful to Mira Mezini for writing the Koreferat and for accepting to be on the PhD committee, as well as for coming to Switzerland to join the jury of the PhD defense. Also, I thank Matthias Zwicker for accepting to chair the examination. I would like to thank Gustavo Rossi and Fernando Aramburu for believing in me before I did. This thesis would have never existed without you two. I am grateful to Stéphane Ducasse and Marcus Denker for their enthusiasm and positive support. I would like to thank them for introducing me into the reflection and meta-programming problems that this thesis addresses. I thank Tudor Gîrba for the inspiring discussions and for providing many of the ideas that have influenced this work. I also thank Alexandre Bergel for his support, interesting dicusssions and for providing new ideas and applications for the tools presented in this thesis. I am much obliged to the people that provided constructive feedback on early drafts of this dissertation: Orla Greevy, Fabrizio Perin, and Lukas Renggli. This thesis would have never been completed without Fabrizio Perin and Lukas Renggli. Their emotional and technical support are directly related to the results of this thesis. Special thanks go to Iris Keller who made the administrative work both inside and outside the university a pleasure. I would like to thank my master students Andrea Quadri and Daniel Langone, and my bachelor students Max Leske, Manuel Leuenberger and Chantal Peeters for the hours we shared discussing and implementing Smalltalk projects and for putting up with my rather unconventional approach to research. I would like to thank all the former and current members of the Software Composition Group. It was a pleasure to work with you: Andrea Caracciolo, Marcus Denker, Tu- dor Gîrba, Adrian Kuhn, Jan Kurš, Adrian Lienhard, Mircea Lungu, Fabrizio Perin, David Röthlisberger, Niko Schwarz, Toon Verwaest, and Erwann Wernli. I thank the people with whom I shared many interesting discussions at confer- ences: Nick Ager, Marco D’Ambros, Michele Lanza, Philippe Marschall, Fernando i Oliveros, Serge Stinckwich and Adrian van Os. Special thanks to the early fanati- cal Bifröst supporters and believers who kept me going: Alexandre Bergel, Noury Bouraqadi, Jordi Delgado, Simon Dennier, Luc Fabresse, Dale Henrichs, Rafael Luque and Erwann Wernli. I would like to deeply thank Angela for making us feel like home. Many, many thanks to my family. Thanks for your love and support: Ricardo, Cristina, Mariana, Luciana, Isabella, Roman, Hernan and Adrian. Above all, I thank my wife Analia Magurno for putting up with me, which is quite difficult. Jorge Ressia October 8, 2012 To Carmela and Nelly Abstract Reflective applications are able to query and manipulate the structure and behav- ior of a running system. This is essential for highly dynamic software that needs to interact with objects whose structure and behavior are not known when the ap- plication is written. Software analysis tools, like debuggers, are a typical example. Oddly, although reflection essentially concerns run-time entities, reflective appli- cations tend to focus on static abstractions, like classes and methods, rather than objects. This is phenomenon we call the object paradox, which makes developers less effective by drawing their attention away from run-time objects. To counteract this phenomenon, we propose a purely object-centric approach to re- flection. Reflective mechanisms provide object-specific capabilities as another fea- ture. Object-centric reflection proposes to turn this around and put object-specific capabilities as the central reflection mechanism. This change in the reflection archi- tecture allows a unification of various reflection mechanisms and a solution to the object paradox. We introduce Bifröst, an object-centric reflective system based on first-class meta- objects. Through a series of practical examples we demonstrate how object-centric reflection mitigates the object paradox by avoiding the need to reflect on static ab- stractions. We survey existing approaches to reflection to establish key requirements in the domain, and we show that an object-centric approach simplifies the meta-level and allows a unification of the reflection field. We demonstrate how development it- self is enhanced with this new approach: talents are dynamically composable units of reuse, and object-centric debugging prevents the object paradox when debugging. We also demonstrate how software analysis is benefited by object-centric reflection with Chameleon, a framework for building object-centric analysis tools and MetaSpy, a domain-specific profiler. v Contents 1 Introduction 1 1.1 Reflection Requirements ........................ 1 1.2 The Problem ............................... 2 1.3 Problem Statement ........................... 5 1.4 Challenges ................................ 6 1.5 Thesis Statement ............................ 7 1.6 Our Solution in a Nutshell ....................... 7 1.7 Contributions .............................. 10 1.8 Outline .................................. 11 2 Reflection State Of The Art 15 2.1 Applications of Reflection ....................... 15 2.2 Reflection Dimensions ......................... 16 2.2.1 Definition ............................ 16 2.2.2 Elements ............................. 16 2.2.3 Models .............................. 17 2.2.4 Constructs ............................ 18 2.3 State of the Art in Meta-level Engineering ............... 18 2.3.1 Reflection requirements .................... 18 2.3.2 Summary ............................ 28 3 Object-Centric Reflection 29 3.1 Object-Centric Reflection in a Nutshell ................ 29 3.2 Meta-objects ............................... 30 3.2.1 Structural Meta-object ..................... 31 3.2.2 Behavioral Meta-object ..................... 31 3.2.3 Compound Meta-object ..................... 32 3.2.4 Scoping Meta-object adaptations ................ 32 3.3 Meta-object Definition ......................... 34 3.4 Unification of Reflection ........................ 34 3.5 Object Paradox ............................. 35 4 Bifröst 37 4.1 Meta-objects ............................... 37 4.1.1 Structural Meta-object ..................... 37 4.1.2 Behavioral Meta-object ..................... 38 4.1.3 Compound Meta-object ..................... 39 vii 4.1.4 Low-level Meta-object ..................... 39 4.2 Bifröst Exemplified ........................... 40 4.2.1 Profiling (Scenario 2) ...................... 41 4.2.2 Traits (Scenario 2) ........................ 41 4.2.3 Delegates (Scenario 2) ..................... 44 4.2.4 Prototypes (Scenario 3) ..................... 45 4.2.5 Live Feature Analysis (Scenario 2) ............... 46 4.2.6 Scoped Live Feature Analysis (Scenario 2) .......... 47 4.3 Implementation ............................. 48 4.3.1 Adapting the Lower-level ................... 49 4.3.2 Reflective methods ....................... 49 4.3.3 Structural and Behavioral Reflection .............. 50 4.3.4 Object-specific Behavior .................... 51 4.3.5 Micro-Benchmark ........................ 52 4.3.6 Bifröst for other languages ................... 53 4.4 Conclusion ............................... 54 5 Dynamically Composable Units of Reuse 55 5.1 Motivating Examples .......................... 56 5.1.1 Moose Meta-model ....................... 57 5.1.2 Streams ............................. 58 5.2 Talents in a Nutshell .......................... 58 5.2.1 Defining Talents ......................... 58 5.2.2 Composing Objects from Talents ................ 59 5.2.3 Conflict Resolution ....................... 60 5.2.4 Stateful Talents ......................... 61 5.3 Implementation ............................. 63 5.4 Related Work .............................. 64 5.5 Discussion ................................ 68 5.5.1 Scoping Talents ......................... 68 5.5.2 Flattening ............................ 69 5.5.3 Talents in a statically typed language ............. 69 5.5.4 Traits on Talents ......................... 70 5.6 Examples ................................ 70 5.6.1 Mocking ............................. 71 5.6.2 Compiler Internal Abstractions ................ 71 5.6.3 State Pattern ........................... 72 5.6.4 Streams ............................. 73 5.6.5 Class Extensions ........................ 73 5.7 User Interface .............................. 74 5.8 Conclusion ............................... 76 6 Decoupling Instrumentation from Software Analysis

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    202 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