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

Sound and extensible renaming for java

Published:19 October 2008Publication 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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. AspectJ Development Tools 1.5.1. http://www.eclipse.org/ajdt.Google ScholarGoogle Scholar
  4. John Brant and Don Roberts. The Smalltalk Refactoring Browser. http://st-www.cs.uiuc.edu/users/brant/Refactory/, 1999.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Leonardo Cole and Paulo Borba. Deriving Refactorings for AspectJ. In Aspect-Oriented Software Development (AOSD). ACM Press, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Márcio Lopes Cornélio. Refactorings as Formal Refinements. Ph.D. thesis, Universidade Federal de Pernambuco, 2004.Google ScholarGoogle Scholar
  8. Brett Daniel, Danny Dig, Kely Garcia, and Darko Marinov. Automated Testing of Refactoring Engines. In Proceedings of ESEC/FSE'07. ACM Press, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Eclipse 3.3.1. http://www.eclipse.org, 2007.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Ran Ettinger. Refactoring via Program Slicing and Sliding. D.Phil. thesis, Computing Laboratory, Oxford, UK, 2007.Google ScholarGoogle Scholar
  15. Martin Fowler. Refactoring: improving the design of existing code. Addison Wesley, 2000.Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification. Prentice Hall, 3rd edition, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Stefan Hanenberg, Christian Oberschulte, and Rainer Unland. Refactoring of Aspect-Oriented Software. In Net.ObjectDays, 2003.Google ScholarGoogle Scholar
  19. JBuilder 2007. http://www.codegear.com/products/jbuilder, 2007.Google ScholarGoogle Scholar
  20. IntelliJ IDEA 7.0.1. http://www.jetbrains.com, 2007.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Netbeans 6.0. http://www.netbeans.com, 2007.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  24. William F. Opdyke. Refactoring Object-Oriented Frameworks. PhD thesis, University of Illinois at Urbana-Champaign, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Donald F. Roberts. Practical Analysis for Refactoring. PhD thesis, University of Illinois at Urbana-Champaign, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Semmle. SemmleCode. http://semmle.com, 2008.Google ScholarGoogle Scholar
  27. Nik Sultana and Simon Thompson. Mechanical Verification of Refactorings. In Workshop on Partial Evaluation and Program Manipulation. ACM SIGPLAN, January 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. The AspectJ Team. The AspectJ Programming Guide.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Mathieu Verbaere, Ran Ettinger, and Oege de Moor. JunGL: a Scripting Language for Refactoring. In International Conference on Software Engineering (ICSE '06), 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. w3c. Jigsaw. http://www.w3.org/Jigsaw/, 2006.Google ScholarGoogle Scholar
  33. David Wheeler. SLOCCount. http://www.dwheeler.com/sloccount/, 2006.Google ScholarGoogle Scholar

Index Terms

  1. Sound and extensible renaming for java

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • 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

      Copyright © 2008 ACM

      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]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 19 October 2008

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate268of1,244submissions,22%

      Upcoming Conference

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader