A Program Analysis for Tool-Supported Refactoring of Aspect-Oriented Programs

A Program Analysis for Tool-Supported Refactoring of Aspect-Oriented Programs

A Program Analysis for Tool-supported Refactoring of Aspect-oriented Programs Jan Wloka Stefan Jahnichen¨ Fraunhofer FIRST Technical University Berlin Kekulstr. 7 Franklinstr. 28/29 Berlin, Germany Berlin, Germany jan.wloka@first.fraunhofer.de [email protected] Categories and Subject Descriptors control flow. A pointcut expresses a join point property by D.2.7 [Software Engineering]: Distribution, Maintenance, referencing the anchor structures and elements, and thereby and Enhancement; F.3.2 [Logics and Meanings of Pro- ties the advice execution closely to these implementation in- grams]: Semantics of Programming Languages—program ternals. For example, the pointcut analysis; D.3.3 [Programming Languages]: Language Con- call(public int A.bar()) structs and Features—patterns, classes and objects && withincode(public void A.foo()) selects all method calls of method bar() that are defined General Terms within method foo(). Additionally, it references the decla- Algorithms, Measurement, Languages, Reliability rations of class A and method foo(), although these ele- ments does not belong to the selected join point set. Hence, Keywords any modification of class A or method foo(), e.g., by a refactoring, does not modify selected join points, but may Software refactoring, Aspect-oriented programming, Change break the pointcut and therefore the specified advice execu- impact analysis, Static program analysis, Code generation tion. Refactorings for aspect-oriented programs have to preserve 1. PROBLEM & MOTIVATION the anchor structures and elements but also still allow to im- Aspect-oriented programming (AOP) has been proposed prove the program’s design. A refactoring tool that is able to for improving the modularity of implementations that can- identify these structures, can allow safe modifications (even not be encapsulated with traditional means, so called cross- if they affect the set of selected join points), identify and cutting concerns. It introduces new adaptation concepts adjust affected pointcuts and prevent the programmer from that allow the structural extension of implementation mod- breaking a pointcut. ules and the adaptation of existing program behavior. The adaptation concepts are often achieved by new language 2. RESEARCH PROPOSAL mechanisms and constructs, such as pointcut and advice. A A classification of the change impact of object-oriented pointcut specifies where and when an advice is executed by refactorings on pointcuts is investigated to cope with the selecting well-defined points in the program execution, so fragile pointcut problem in tool-supported refactoring. called join points. Every time a join point is executed, some runtime support looks for matching pointcuts. If a matching 3. BACKGROUND & RELATED WORK pointcut is defined, every bound advice is executed. With this complex but powerful mechanism, aspects can declare Various approaches have been proposed to cope with the an adaptation without modifying the source of the adapted issues arisen by the tight coupling between aspects and the implementation module. base program. The most related results provide extensions For selecting a set of join points, a pointcut can specify to object-oriented refactorings, new IDE support for deter- structural and behavioral properties that have all desired mining altered pointcut matches and more expressive point- join points in common. These properties are anchored in cut languages, making a pointcut less coupled to brittle im- internal program structures, such as the program’s name plementation details. This section describes the refactoring space, code containment, inheritance relationships or the and program analysis related approaches in more detail. 3.1 Aspect-oriented Refactoring In [4, 1, 2, 7, 3, 9] new refactorings for aspect-oriented Permission to make digital or hard copies of all or part of this work for programs has been identified which allow the improvement personal or classroom use is granted without fee provided that copies are of object-oriented programs by using AO-modlarization, the not made or distributed for profit or commercial advantage and that copies refactoring of aspect language constructs or the refactoring bear this notice and the full citation on the first page. To copy otherwise, to of base code while existing AO adaptations are preserved. republish, to post on servers or to redistribute to lists, requires prior specific In particular, Monteiro et al. have published in [4] a cata- permission and/or a fee. Doctoral Symposium FSE 14, 2006 Portland, Oregon USA logue of new refactorings and bad smells for AspectJ pro- Copyright 2006 ACM X-XXXXX-XX-X/XX/XX ...$5.00. grams. Ceccato et al. present in[1] an AOPMigrator which supports to different program versions or by analyzing the applied the extraction of class members and statements into aspects. changes. They propose a specific refactoring workflow that generates An approach that detects differently bound advices by com- a single pointcut for every extracted program element. paring two program versions is presented by St¨orzerand Hannemann et al. present in [2] also a tool for extracting Graf in [10]. The proposed pointcut delta analysis approxi- crosscutting concerns into aspects. The tool supports a spe- mates the bound join points for every pointcut and compares cific workflow for migrating design patterns implemented in the pointcut matches between two program versions. New, Java to an AspectJ implementation. lost and modified (in terms of match quality) matches are discovered. All these refactoring approaches have to cope with base Our change impact analysis extends this approach in sev- code changes that may affect existing pointcuts. Our ap- eral ways. The computed match delta is extended to a so proach reveals altered join point selections, proposes suit- called pointcut selection delta that contains matches of ev- able pointcut updates and generates rephrased pointcuts. ery referenced program structure, rather than only complete Thus it can be seen as fundamental to AO refactoring in pointcut matches. The selection delta entries are directly general. associated with the responsible change. This direct associa- tion allows the automated calculation of pointcut updates. 3.2 Behavior Preservation in AO Refactoring Hanenberg et al. describe in [9] initial ideas on how to Similar to Ryder et al. in [6, 8] we divide program edits treat pointcuts within a refactoring workflow. They ex- (performed by a refactoring) into their constituent atomic tended the refactoring constraints to preserve the number changes amenable to program analysis. Atomic changes of selected join points, the position of a selected join point have syntactic dependencies, denoting prerequisite relation- within the program’s control flow and the information pro- ships and represent a distinct impact on the program’s source. vided at a selected join point for every pointcut. Based on Based on the atomic change model Ryder et al. have devel- these additional constraints, the previous program behavior oped different change classifications that indicate the likeli- is reestablished by updating affected pointcuts. hood of a change to be failure-inducing. Every change can Two problems are not considered in this approach: (i) a be labeled, as red (highly likely to be failure-inducing), yel- pointcut may intentionally select additional join points after low (somewhere in between) or green (highly unlikely to be a refactoring and (ii) join points are points in the program failure-inducing). execution which have to be statically approximated. In contrast to Ryder et al. we do not employ the atomic Rura and Lerner advance the AO-specific refactoring con- changes to identify affected unit tests, but affected point- straints in [7]. They present a ”pointcut pattern equiva- cuts. Our change classification indicates the likelihood of a lence” constraint, that reduces the rule ”each advice must change to break the program structures a pointcut relies on. apply at semantically equivalent join points” to a more sim- A combination of both approaches allows to separate changes ple determinable but stronger requirement ”signature pat- that just alter the set of pointcut matches from changes terns used in a pointcut must match semantically equivalent that break the pointcut. With this separation a tool can program elements”. In cases where the signature patterns be enabled to deny critical transformations while it safely do not match the same elements as before the refactoring, performs all others. the patterns are broadened/narrowed in a way that new and lost pattern matches are prevented. 4. HYPOTHESIS However, additional and lost matches are always excluded In aspect-oriented programs, a pointcut defines where and or included, which makes, on the one hand, pointcuts un- when advices are executed by selecting a set of join points. recognizable and worse readable, and, on the other hand, It can specify some structural and behavioral properties that it does not consider the programmer’s intention behind a have all join points in common. A set of selected join points pointcut. can be unintentionally altered through various (even local) source code changes. In order to decide if a certain change Our approach can be seen as an extension to this work. actually breaks a pointcut, two different kinds of changes We explicitly consider the change impact of a refactoring have to be distinguished: changes that affect a program ele- by assigning atomic changes with a distinct impact on a ment that possesses specified properties

View Full Text

Details

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