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.
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- AspectJ Development Tools 1.5.1. http://www.eclipse.org/ajdt.Google Scholar
- John Brant and Don Roberts. The Smalltalk Refactoring Browser. http://st-www.cs.uiuc.edu/users/brant/Refactory/, 1999.Google Scholar
- 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 ScholarDigital Library
- Leonardo Cole and Paulo Borba. Deriving Refactorings for AspectJ. In Aspect-Oriented Software Development (AOSD). ACM Press, 2005. Google ScholarDigital Library
- Márcio Lopes Cornélio. Refactorings as Formal Refinements. Ph.D. thesis, Universidade Federal de Pernambuco, 2004.Google Scholar
- Brett Daniel, Danny Dig, Kely Garcia, and Darko Marinov. Automated Testing of Refactoring Engines. In Proceedings of ESEC/FSE'07. ACM Press, 2007. Google ScholarDigital Library
- 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 ScholarDigital Library
- Eclipse 3.3.1. http://www.eclipse.org, 2007.Google Scholar
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Ran Ettinger. Refactoring via Program Slicing and Sliding. D.Phil. thesis, Computing Laboratory, Oxford, UK, 2007.Google Scholar
- Martin Fowler. Refactoring: improving the design of existing code. Addison Wesley, 2000.Google ScholarDigital Library
- James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification. Prentice Hall, 3rd edition, 2005. Google ScholarDigital Library
- 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 ScholarDigital Library
- Stefan Hanenberg, Christian Oberschulte, and Rainer Unland. Refactoring of Aspect-Oriented Software. In Net.ObjectDays, 2003.Google Scholar
- JBuilder 2007. http://www.codegear.com/products/jbuilder, 2007.Google Scholar
- IntelliJ IDEA 7.0.1. http://www.jetbrains.com, 2007.Google Scholar
- 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 ScholarDigital Library
- Netbeans 6.0. http://www.netbeans.com, 2007.Google Scholar
- 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 Scholar
- William F. Opdyke. Refactoring Object-Oriented Frameworks. PhD thesis, University of Illinois at Urbana-Champaign, 1992. Google ScholarDigital Library
- Donald F. Roberts. Practical Analysis for Refactoring. PhD thesis, University of Illinois at Urbana-Champaign, 1999. Google ScholarDigital Library
- Semmle. SemmleCode. http://semmle.com, 2008.Google Scholar
- Nik Sultana and Simon Thompson. Mechanical Verification of Refactorings. In Workshop on Partial Evaluation and Program Manipulation. ACM SIGPLAN, January 2008. Google ScholarDigital Library
- The AspectJ Team. The AspectJ Programming Guide.Google Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Mathieu Verbaere, Ran Ettinger, and Oege de Moor. JunGL: a Scripting Language for Refactoring. In International Conference on Software Engineering (ICSE '06), 2006. Google ScholarDigital Library
- w3c. Jigsaw. http://www.w3.org/Jigsaw/, 2006.Google Scholar
- David Wheeler. SLOCCount. http://www.dwheeler.com/sloccount/, 2006.Google Scholar
Index Terms
- Sound and extensible renaming for java
Recommendations
The jastadd extensible java compiler
OOPSLA '07: Proceedings of the 22nd annual ACM SIGPLAN conference on Object-oriented programming systems, languages and applicationsThe JastAdd Extensible Java Compiler is a high quality Java compiler that is easy to extend in order to build static analysis tools for Java, and to extend Java with new language constructs. It is built modularly, with a Java 1.4 compiler that is ...
Refactoring is not (yet) about transformation
WRT '08: Proceedings of the 2nd Workshop on Refactoring ToolsIn order to ensure correctness, refactorings have to check extensive preconditions before performing the transformation. These preconditions usually involve subtle analyses of the program to be refactored, and as long as there is no good support for ...
Sound and extensible renaming for java
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 ...
Comments