Transforming Programs between APIs with Many-to-Many Mappings

Authors Chenglong Wang, Jiajun Jiang, Jun Li, Yingfei Xiong, Xiangyu Luo, Lu Zhang, Zhenjiang Hu



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2016.25.pdf
  • Filesize: 0.76 MB
  • 26 pages

Document Identifiers

Author Details

Chenglong Wang
Jiajun Jiang
Jun Li
Yingfei Xiong
Xiangyu Luo
Lu Zhang
Zhenjiang Hu

Cite As Get BibTex

Chenglong Wang, Jiajun Jiang, Jun Li, Yingfei Xiong, Xiangyu Luo, Lu Zhang, and Zhenjiang Hu. Transforming Programs between APIs with Many-to-Many Mappings. In 30th European Conference on Object-Oriented Programming (ECOOP 2016). Leibniz International Proceedings in Informatics (LIPIcs), Volume 56, pp. 25:1-25:26, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2016) https://doi.org/10.4230/LIPIcs.ECOOP.2016.25

Abstract

Transforming programs between two APIs or different versions of
the same API is a common software engineering task. However,
existing languages supporting for such transformation cannot
satisfactorily handle the cases when the relations between
elements in the old API and the new API are many-to-many
mappings: multiple invocations to the old API are supposed to be
replaced by multiple invocations to the new API. Since the
multiple invocations of the original APIs may not appear
consecutively and the variables in these calls may have different
names, writing a tool correctly to cover all such invocation
cases is not an easy task.  In this paper we propose a novel
guided-normalization approach to address this problem. Our core
insight is that programs in different forms can be
semantics-equivalently normalized into a basic form guided by
transformation goals, and developers only need to write rules for
the basic form to address the transformation. Based on this
approach, we design a declarative program transformation
language, PATL, for adapting Java programs between different
APIs. PATL has simple syntax and basic semantics to handle
transformations only considering consecutive statements inside
basic blocks, while with guided-normalization, it can be extended
to handle complex forms of invocations. Furthermore, PATL ensures
that the user-written rules would not accidentally break def-use
relations in the program.  We formalize the semantics of PATL on
Middleweight Java and prove the semantics-preserving property of
guided-normalization. We also evaluated our language with three
non-trivial case studies: i.e. updating Google Calendar API,
switching from JDom to Dom4j, and switching from Swing to
SWT. The result is encouraging; it shows that our language allows
successful transformations of real world programs with a small
number of rules and little manual resolution.

Subject Classification

Keywords
  • Program transformation
  • API migration

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools (2Nd Edition). Addison-Wesley, 2006. Google Scholar
  2. Jesper Andersen, Anh Cuong Nguyen, David Lo, Julia L. Lawall, and Siau-Cheng Khoo. Semantic patch inference. In ASE, 2012. Google Scholar
  3. Ittai Balaban, Frank Tip, and Robert Fuhrer. Refactoring support for class library migration. In OOPSLA, 2005. Google Scholar
  4. Thiago Tonelli Bartolomei, Krzysztof Czarnecki, Ralf Lämmel, and Tijs van der Storm. Study of an api migration for two xml apis. In SLE, 2010. Google Scholar
  5. G.M. Bierman, M.J. Parkinson, and A.M. Pitts. MJ: An imperative core calculus for Java and Java with effects. Technical Report UCAM-CL-TR-563, University of Cambridge, Computer Laboratory, 2003. URL: http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-563.pdf.
  6. Martin Bravenboer, Karl Trygve Kalleberg, Rob Vermaas, and Eelco Visser. Stratego/xt 0.17. a language and toolset for program transformation. Sci. Comput. Program., 72(1-2), June 2008. URL: http://dx.doi.org/10.1016/j.scico.2007.11.003,
  7. Julien Brunel, Damien Doligez, René Rydhof Hansen, Julia L. Lawall, and Gilles Muller. A foundation for flow-based program matching: using temporal logic and model checking. In POPL, 2009. Google Scholar
  8. David Callahan, Keith D. Cooper, Ken Kennedy, and Linda Torczon. Interprocedural constant propagation. In CC, 1986. Google Scholar
  9. James R. Cordy. The TXL source transformation language. Sci. Comput. Program., 61(3), 2006. Google Scholar
  10. Thomas H. Cormen, Clifford Stein, Ronald L. Rivest, and Charles E. Leiserson. Introduction to Algorithms. McGraw-Hill Higher Education, 2nd edition, 2001. Google Scholar
  11. Danny Dig and Ralph Johnson. How do APIs evolve? a story of refactoring: Research articles. J. Softw. Maint. Evol., 18(2), 2006. Google Scholar
  12. Danny Dig, Stas Negara, Vibhu Mohindra, and Ralph E. Johnson. ReBA: refactoring-aware binary adaptation of evolving libraries. In ICSE, 2008. Google Scholar
  13. Johannes Henkel and Amer Diwan. Catchup!: Capturing and replaying refactorings to support api evolution. In ICSE, 2005. Google Scholar
  14. Aditya Kanade, Amitabha Sanyal, and Uday P. Khedker. A PVS based framework for validating compiler optimizations. In SEFM, 2006. Google Scholar
  15. Jens Knoop, Oliver Rüthing, and Bernhard Steffen. Lazy code motion. In PLDI, 1992. Google Scholar
  16. Raghavan Komondoor and Susan Horwitz. Semantics-preserving procedure extraction. In POPL, 2000. Google Scholar
  17. David Lacey and Oege de Moor. Imperative program transformation by rewriting. In CC, pages 52-68, 2001. Google Scholar
  18. Jun Li, Chenglong Wang, Yingfei Xiong, and Zhenjiang Hu. Swin: Towards type-safe java program adaptation between apis. In PEPM, 2015. Google Scholar
  19. Jun Li, Yingfei Xiong, Xuanzhe Liu, and Lu Zhang. How does web service api evolution affect clients? In ICWS, 2013. Google Scholar
  20. Deling Ren Martin Erwig. Type-safe update programming. In ESOP, 2003. Google Scholar
  21. Deling Ren Martin Erwig. An update calculus for expressing type-safe program updates. Science of Computer Programming, 67, 2007. Google Scholar
  22. Na Meng, Miryung Kim, and Kathryn S. McKinley. Systematic editing: Generating program transformations from an example. In PLDI, 2011. Google Scholar
  23. Hoan Anh Nguyen, Tung Thanh Nguyen, Gary Wilson, Jr., Anh Tuan Nguyen, Miryung Kim, and Tien N. Nguyen. A graph-based approach to API usage adaptation. In OOPSLA, 2010. Google Scholar
  24. Marius Nita and David Notkin. Using twinning to adapt programs to alternative APIs. In ICSE, 2010. Google Scholar
  25. Karina Olmos and Eelco Visser. Composing source-to-source data-flow transformations with rewriting strategies and dependent dynamic rewrite rules. In CC, 2005. Google Scholar
  26. William F. Opdyke. Refactoring Object-oriented Frameworks. PhD thesis, University of Illinois at Urbana-Champaign, 1992. Google Scholar
  27. Yoann Padioleau, Julia Lawall, René Rydhof Hansen, and Gilles Muller. Documenting and automating collateral evolutions in linux device drivers. In Eurosys, 2008. Google Scholar
  28. Nicolas Palix, Jean-Rémy Falleri, and Julia Lawall. Improving pattern tracking with a language-aware tree differencing algorithm. In SANER, 2015. Google Scholar
  29. Benjamin C. Pierce. Types and Programming Languages. 2002. Google Scholar
  30. Mark Pilgrim. Dive Into Python 3. Apress, 2009. Google Scholar
  31. Donald Bradley Roberts. Practical Analysis for Refactoring. PhD thesis, University of Illinois at Urbana-Champaign, 1999. Google Scholar
  32. Kouhei Sakurai and Hidehiko Masuhara. Crossver: a code transformation language for crosscutting changes. In AOAsia/Pacific Workshop, 2014. Google Scholar
  33. Max Schäfer, Torbjörn Ekman, and Oege de Moor. Sound and extensible renaming for java. In OOPSLA, 2008. Google Scholar
  34. Thiago Tonelli Bartolomei, Krzysztof Czarnecki, and Ralf Lämmel. Swing to SWT and back: Patterns for API migration by wrapping. In ICSM, 2010. Google Scholar
  35. Raja Vallée-Rai, Phong Co, Etienne Gagnon, Laurie Hendren, Patrick Lam, and Vijay Sundaresan. Soot - a Java bytecode optimization framework. In CASCON, 1999. Google Scholar
  36. Louis Wasserman. Scalable, example-based refactorings with refaster. In WRT, 2013. Google Scholar
  37. Mark N. Wegman and F. Kenneth Zadeck. Constant propagation with conditional branches. ACM Trans. Program. Lang. Syst., 13(2), April 1991. Google Scholar
  38. Daniel Weise and Roger Crew. Programmable syntax macros. In PLDI, 1993. Google Scholar
  39. Qian Wu, Guangtai Liang, Qianxiang Wang, and Hong Mei. Mining effective temporal specifications from heterogeneous API data. J. Comput. Sci. Technol., 26(6), 2011. Google Scholar
  40. Hao Zhong, Suresh Thummalapenta, Tao Xie, Lu Zhang, and Qing Wang. Mining API mapping for language migration. In ICSE, 2010. Google Scholar
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail