Abstract
One of the most difficult parts of building automated refactorings is ensuring that they preserve behavior. This paper proposes a new technique to check for behavior preservation; we call this technique differential precondition checking. It is simple yet expressive enough to implement the most common refactorings, and the core algorithm runs in linear time. However, the main advantage is that a differential precondition checker can be placed in a library and reused in refactoring tools for many different languages; the core algorithm can be implemented in a way that is completely language independent. We have implemented a differential precondition checker and used it in refactoring tools for Fortran (Photran), PHP, and BC.



Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.Notes
Why differential “precondition” checking? A refactoring takes user input \(I\) and uses it to determine a program transformation \(T(I)\). However, a precondition for the application of \(T(I)\) to the user’s source code is that it satisfies the properties of compilability and preservation.
Bugs 177636, 194996, 194997, 195002, 195004, 194005, and 195006.
A slightly more complete and much more detailed specification for this refactoring is given in the technical report Overbey et al. (2011) described in the Evaluation section of this paper.
Again, a more complete and detailed specification is available Overbey et al. (2011).
Actually, in practice, the requirement is not so strict: Two tree nodes can correspond to the same textual region as long as only one of them can ever occur as the endpoint of a semantic edge in a program graph.
The tests were performed on a 2.3 GHz Intel Core i7 (MacBook Pro), Java 1.6.0_51, with the JVM heap limited to 512 MB.
References
Daniel, B., Dig, D., Garcia, K., Marinov, D.: Automated testing of refactoring engines. In: Proceedings of the the 6th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering (FSE ’07). ACM, New York, (2007)
Dig, D., Marrero, J., Ernst, M.D.: Refactoring sequential Java code for concurrency via concurrent libraries. In: Proceedings of the 31st International Conference on Software Engineering. IEEE Computer Society (ICSE ’09), Washington, DC, pp. 397–407 (2009)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley, Reading, MA (1995)
Kennedy, Ken, Allen, John R.: Optimizing Compilers for Modern Architectures: A Dependence-Based Approach. Morgan Kaufmann, San Francisco (2002)
Mens, Tom, van Eetvelde, N., Demeyer, S., Janssens, D.: Formalizing Refactorings with Graph Transformations. J. Softw. Maint. Evol. 17(4), 247–276 (2005)
Murphy-Hill, E., Parnin, C., Black, A.P..: How we refactor, and how we know it. In: Proceedings of the 31st International Conference on Software Engineering (ICSE ’09), pp. 287–297 (2009)
Overbey, J.L., Fotzler, M.J., Kasza, A.J., Johnson, R.E.: A Collection of Refactoring Specifications for Fortran 95, BC, and PHP 5. Technical Report http://jeff.over.bz/papers/2011/tr-refacs.pdf (2011)
Overbey, J.L., Johnson, R.E.: Differential precondition checking: a lightweight, reusable analysis for refactoring tools. In: 26th IEEE/ACM International Conference on Automated Software Engineering (ASE ’11), pp. 303–312. Lawrence (2011)
Overbey, J.L., Johnson, R.E.: Generating rewritable abstract syntax trees. In: Software Language Engineering. Lecture Notes in Computer Science, vol. 5452, pp. 114–133. Springer, Berlin (2008)
Reichenbach, C., Coughlin, D., Diwan, A.: Program metamorphosis. In: Proceedings of the 23rd European Conference on Object Oriented Programming (ECOOP ’09) (2009)
Schäfer, M., de Moor, O.: Specifying and implementing refactorings. In: ACM Sigplan Notices (SPLASH ’10), vol. 45, pp. 286–301 (2010)
Schäfer, M., Dolby, J., Sridharan, M., Tip, F., Torlak, E.: Correct refactoring of concurrent Java code. In: 24th European Conference on Object-Oriented Programming (ECOOP ’10). Springer, Berlin (2010)
Schäfer, M., Ekman, T., de Moor, O.: Sound and extensible renaming for Java. In: 23rd Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA ’08). ACM Press, New York (2008)
Schäfer, M., Verbaere, M., Ekman, T., de Moor, O.: Stepping stones over the refactoring rubicon—lightweight language extensions to easily realise refactorings. In: ECOOP ’09 (2009)
Verbaere, M., Ettinger, R., de Moor, O.: JunGL: a scripting language for refactoring. In: Proceedings of the 28th International Conference on Software Engineering (ICSE’06). ACM, New York (2006)
Acknowledgments
This research is part of the Blue Waters sustained-petascale computing project, which is supported by the National Science Foundation (Award Number OCI 07-25070) and the state of Illinois. Blue Waters is a joint effort of the University of Illinois at Urbana-Champaign, its National Center for Supercomputing Applications, IBM, and the Great Lakes Consortium for Petascale Computation. Additionally, portions of this research were supported by the National Science Foundation under award CCF-1217271. The authors would like to thank the anonymous reviewers, as well as Rob Bocchino, John Brant, Brett Daniel, Danny Dig, Matthew Fotzler, Milos Gligoric, Vilas Jagannath, Ashley Kasza, Darko Marinov, Stas Negara, and members of the Brett Daniel Software Engineering Seminar for providing invaluable feedback on earlier drafts of this paper.
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
About this article
Cite this article
Overbey, J.L., Johnson, R.E. & Hafiz, M. Differential precondition checking: a language-independent, reusable analysis for refactoring engines. Autom Softw Eng 23, 77–104 (2016). https://doi.org/10.1007/s10515-014-0176-9
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10515-014-0176-9