skip to main content
10.1145/1449764.1449787acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Sound and extensible renaming for java

Published: 19 October 2008 Publication History

Abstract

Descriptive names are crucial to understand code. However, good names are notoriously hard to choose and manually changing a globally visible name can be a maintenance nightmare. Hence, tool support for automated renaming is an essential aid for developers and widely supported by popular development environments.
This work improves on two limitations in current refactoring tools: too weak preconditions that lead to unsoundness where names do not bind to the correct declarations after renaming, and too strong preconditions that prevent renaming of certain programs. We identify two main reasons for unsoundness: complex name lookup rules make it hard to define sufficient preconditions, and new language features require additional preconditions. We alleviate both problems by presenting a novel extensible technique for creating symbolic names that are guaranteed to bind to a desired entity in a particular context by inverting lookup functions. The inverted lookup functions can then be tailored to create qualified names where otherwise a conflict would occur, allowing the refactoring to proceed and improve on the problem with too strong preconditions.
We have implemented renaming for Java as an extension to the JastAdd Extensible Java Compiler and integrated it in Eclipse. We show examples for which other refactoring engines have too weak preconditions, as well as examples where our approach succeeds in renaming entities by inserting qualifications. To validate the extensibility of the approach we have implemented renaming support for Java 5 and AspectJ like inter-type declarations as modular extensions to the initial Java 1.4 refactoring engine. The renaming engine is only a few thousand lines of code including extensions and performance is on par with industrial strength refactoring tools.

References

[1]
Johan Åkesson, Torbjörn Ekman, and Görel Hedin. Development of a Modelica Compiler Using Jast-Add. Electronic Notes in Theoretical Computer Science, 203(2):117--131, 2008.
[2]
Pavel Avgustinov, Torbjörn Ekman, and Julian Tibble. Modularity First: A Case for Mixing AOP and Attribute Grammars. In Aspect-Oriented Software Development (AOSD). ACM Press, 2008.
[3]
AspectJ Development Tools 1.5.1. http://www.eclipse.org/ajdt.
[4]
John Brant and Don Roberts. The Smalltalk Refactoring Browser. http://st-www.cs.uiuc.edu/users/brant/Refactory/, 1999.
[5]
Ittai Balaban, Frank Tip, and Robert Fuhrer. Refactoring support for class library migration. In Proceedings of the 20th ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 265---279, 2005.
[6]
Leonardo Cole and Paulo Borba. Deriving Refactorings for AspectJ. In Aspect-Oriented Software Development (AOSD). ACM Press, 2005.
[7]
Márcio Lopes Cornélio. Refactorings as Formal Refinements. Ph.D. thesis, Universidade Federal de Pernambuco, 2004.
[8]
Brett Daniel, Danny Dig, Kely Garcia, and Darko Marinov. Automated Testing of Refactoring Engines. In Proceedings of ESEC/FSE'07. ACM Press, 2007.
[9]
Alan Donovan, Adam Kiezun, Matthew S. Tschantz, and Michael D. Ernst. Converting Java Programs to use Generic Libraries. In Object--Oriented Programming, Systems and Languages, pages 15--34, 2004.
[10]
Eclipse 3.3.1. http://www.eclipse.org, 2007.
[11]
Torbjörn Ekman, Ran Ettinger, Max Schäfer, and Mathieu Verbaere. Refactoring bugs in Eclipse, IDEA and Visual Studio, 2008. http://progtools.comlab.ox.ac.uk/refactoring/bugreports.
[12]
Torbjörn Ekman and Görel Hedin. Modular name analysis for Java using JastAdd. In Generative and Transformational Techniques in Software Engineering, International Summer School, GTTSE 2005, volume 4143 of LNCS. Springer, 2006.
[13]
Torbjörn Ekman and Görel Hedin. The JastAdd Extensible Java Compiler. In Richard P. Gabriel, editor, ACM Conference on Object-Oriented Programming, Systems and Languages (OOPSLA). ACM Press, 2007.
[14]
Ran Ettinger. Refactoring via Program Slicing and Sliding. D.Phil. thesis, Computing Laboratory, Oxford, UK, 2007.
[15]
Martin Fowler. Refactoring: improving the design of existing code. Addison Wesley, 2000.
[16]
James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification. Prentice Hall, 3rd edition, 2005.
[17]
Alejandra Garrido and José Meseguer. Formal Specification and Verification of Java Refactorings. In Proceedings of the Sixth IEEE International Workshop on Source Code Analysis and Manipulation (SCAM), 2006.
[18]
Stefan Hanenberg, Christian Oberschulte, and Rainer Unland. Refactoring of Aspect-Oriented Software. In Net.ObjectDays, 2003.
[19]
JBuilder 2007. http://www.codegear.com/products/jbuilder, 2007.
[20]
IntelliJ IDEA 7.0.1. http://www.jetbrains.com, 2007.
[21]
Tom Mens, Serge DeMeyer, and Dirk Janssens. Formalising behaviour preserving program transformations. In Graph Transformation, volume 2505 of Lecture Notes in Computer Science, pages 286--301, 2002.
[22]
Netbeans 6.0. http://www.netbeans.com, 2007.
[23]
William F. Opdyke and Ralph E. Johnson. Refactoring: An aid in designing application frameworks and evolving object-oriented systems. In Proceedings of Symposium on Object-Oriented Programming Emphasizing Practical Applications (SOOPPA), September 1990.
[24]
William F. Opdyke. Refactoring Object-Oriented Frameworks. PhD thesis, University of Illinois at Urbana-Champaign, 1992.
[25]
Donald F. Roberts. Practical Analysis for Refactoring. PhD thesis, University of Illinois at Urbana-Champaign, 1999.
[26]
Semmle. SemmleCode. http://semmle.com, 2008.
[27]
Nik Sultana and Simon Thompson. Mechanical Verification of Refactorings. In Workshop on Partial Evaluation and Program Manipulation. ACM SIGPLAN, January 2008.
[28]
The AspectJ Team. The AspectJ Programming Guide.
[29]
Frank Tip. Refactoring for generalization using type constraints. In Proceedings of the 18th ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 13--26, 2003.
[30]
Daniel von Dincklage and Amer Diwan. Converting Java classes to use generics. In Proceedings of the 19th ACM Conference on Object--Oriented Programming, Systems, Languages, and Applications, pages 1--14, 2004.
[31]
Mathieu Verbaere, Ran Ettinger, and Oege de Moor. JunGL: a Scripting Language for Refactoring. In International Conference on Software Engineering (ICSE '06), 2006.
[32]
w3c. Jigsaw. http://www.w3.org/Jigsaw/, 2006.
[33]
David Wheeler. SLOCCount. http://www.dwheeler.com/sloccount/, 2006.

Cited By

View all

Index Terms

  1. Sound and extensible renaming for java

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    OOPSLA '08: Proceedings of the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications
    October 2008
    654 pages
    ISBN:9781605582153
    DOI:10.1145/1449764
    • cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 43, Issue 10
      September 2008
      613 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/1449955
      Issue’s Table of Contents
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 19 October 2008

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. extensible compilers
    2. name analysis
    3. refactoring
    4. renaming

    Qualifiers

    • Research-article

    Conference

    OOPSLA08
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 268 of 1,244 submissions, 22%

    Upcoming Conference

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)17
    • Downloads (Last 6 weeks)3
    Reflects downloads up to 23 Dec 2024

    Other Metrics

    Citations

    Cited By

    View all

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media