Skip to main content

Correct Refactoring of Concurrent Java Code

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 6183))

Abstract

Automated refactorings as implemented in modern IDEs for Java usually make no special provisions for concurrent code. Thus, refactored programs may exhibit unexpected new concurrent behaviors. We analyze the types of such behavioral changes caused by current refactoring engines and develop techniques to make them behavior-preserving, ranging from simple techniques to deal with concurrency-related language constructs to a framework that computes and tracks synchronization dependencies. By basing our development directly on the Java Memory Model, we can state and prove precise correctness results about refactoring concurrent programs. We show that a broad range of refactorings are not influenced by concurrency at all, whereas other important refactorings can be made behavior-preserving for correctly synchronized programs by using our framework. Experience with a prototype implementation shows that our techniques are easy to implement and require only minimal changes to existing refactoring engines.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Apache Ant, http://ant.apache.org

  2. Balaban, I., Tip, F., Fuhrer, R.: Refactoring support for class library migration. In: OOPSLA, pp. 265–279 (2005)

    Google Scholar 

  3. Blackburn, S.M., Garner, R., Hoffman, C., Khan, A.M., McKinley, K.S., Bentzur, R., Diwan, A., Feinberg, D., Frampton, D., Guyer, S.Z., Hirzel, M., Hosking, A., Jump, M., Lee, H., Moss, J.E.B., Phansalkar, A., Stefanović, D., Van Drunen, T., von Dincklage, D., Wiedermann, B.: The DaCapo benchmarks: Java benchmarking development and analysis. In: OOPSLA (2006)

    Google Scholar 

  4. Burke, M.G., Choi, J.-D., Fink, S., Grove, D., Hind, M., Sarkar, V., Serrano, M.J., Sreedhar, V.C., Srinivasan, H., Whaley, J.: The Jalapeño dynamic optimizing compiler for Java. In: JAVA 1999, pp. 129–141 (1999)

    Google Scholar 

  5. Cenciarelli, P., Knapp, A., Sibilio, E.: The Java Memory Model: Operationally, Denotationally, Axiomatically. In: De Nicola, R. (ed.) ESOP 2007. LNCS, vol. 4421, pp. 331–346. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  6. Cheng, J.: Slicing Concurrent Programs: A Graph-Theoretical Approach. In: Fritzson, P.A. (ed.) AADEBUG 1993. LNCS, vol. 749. Springer, Heidelberg (1993)

    Chapter  Google Scholar 

  7. Dig, D., Marrero, J., Ernst, M.D.: Refactoring sequential Java code for concurrency via concurrent libraries. In: ICSE, pp. 397–407 (2009)

    Google Scholar 

  8. Dig, D., Tarce, M., Radoi, C., Minea, M., Johnson, R.: RELOOPER: Refactoring for Loop Parallelism in Java. In: OOPSLA Companion (2009)

    Google Scholar 

  9. Ekman, T., Hedin, G.: The JastAdd Extensible Java Compiler. SIGPLAN Notices 42(10), 1–18 (2007)

    Article  Google Scholar 

  10. Ekman, T., Hedin, G.: The JastAdd system — modular extensible compiler construction. Science of Computer Programming 69(1-3), 14–26 (2007)

    Article  MATH  MathSciNet  Google Scholar 

  11. Fowler, M.: Refactoring. Improving the Design of Existing Code. Addison-Wesley, Reading (1999)

    Google Scholar 

  12. Fuhrer, R., Tip, F., Kieżun, A., Dolby, J., Keller, M.: Efficiently refactoring java applications to use generic libraries. In: Black, A.P. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 71–96. Springer, Heidelberg (2005)

    Google Scholar 

  13. Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java Language Specification, 3rd edn. PrenticeHall, Englewood Cliffs (2005)

    Google Scholar 

  14. Griswold, W.G.: Program Restructuring as an Aid to Software Maintenance. Ph.D. thesis, University of Washington (1991)

    Google Scholar 

  15. Huynh, T.Q., Roychoudhury, A.: A memory model sensitive checker for C#. In: Misra, J., Nipkow, T., Sekerinski, E. (eds.) FM 2006. LNCS, vol. 4085, pp. 476–491. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  16. Ševčík, J., Aspinall, D.: On Validity of Program Transformations in the Java Memory Model. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 27–51. Springer, Heidelberg (2008)

    Google Scholar 

  17. Kegel, H., Steimann, F.: Systematically Refactoring Inheritance to Delegation in Java. In: ICSE, pp. 431–440 (2008)

    Google Scholar 

  18. Kieżun, A., Ernst, M., Tip, F., Fuhrer, R.: Refactoring for parameterizing Java classes. In: ICSE, pp. 437–446 (2007)

    Google Scholar 

  19. Krinke, J.: Static Slicing of Threaded Programs. SIGPLAN Not. 33(7) (1998)

    Google Scholar 

  20. Lamport, L.: Time, clocks, and the ordering of events in a distributed system. ACM Commun. 21(7), 558–565 (1978)

    Article  MATH  Google Scholar 

  21. Lea, D.: The JSR-133 Cookbook for Compiler Writers (2008), http://gee.cs.oswego.edu/dl/jmm/cookbook.html

  22. Manson, J., Pugh, W., Adve, S.V.: The Java Memory Model. In: POPL, pp. 378–391. ACM, New York (2005)

    Google Scholar 

  23. Markstrum, S., Fuhrer, R.M., Millstein, T.D.: Towards concurrency refactoring for X10. In: PPOPP, pp. 303–304 (2009)

    Google Scholar 

  24. Naik, M., Aiken, A.: Conditional must not aliasing for static race detection. In: POPL. ACM Press, New York (2007)

    Google Scholar 

  25. Nilsson-Nyman, E., Ekman, T., Hedin, G., Magnusson, E.: Declarative Intraprocedural Flow Analysis of Java Source Code. In: LDTA (2008)

    Google Scholar 

  26. Opdyke, W.F.: Refactoring Object-Oriented Frameworks. PhD thesis, University Of Illinois at Urbana-Champaign (1992)

    Google Scholar 

  27. Schäfer, M., Ekman, T., de Moor, O.: Sound and Extensible Renaming for Java. In: Kiczales, G. (ed.) OOPSLA. ACM Press, New York (2008)

    Google Scholar 

  28. Schäfer, M., Verbaere, M., Ekman, T., de Moor, O.: Stepping Stones over the Refactoring Rubicon – Lightweight Language Extensions to Easily Realise Refactorings. In: Drossopoulou, S. (ed.) ECOOP 2009 – Object-Oriented Programming. LNCS, vol. 5653, pp. 369–393. Springer, Heidelberg (2009)

    Chapter  Google Scholar 

  29. Steimann, F., Thies, A.: From Public to Private to Absent: Refactoring Java Programs under Constrained Accessibility. In: Drossopoulou, S. (ed.) ECOOP 2009 – Object-Oriented Programming. LNCS, vol. 5653, pp. 419–443. Springer, Heidelberg (2009)

    Chapter  Google Scholar 

  30. Tip, F.: Refactoring using type constraints. In: Riis Nielson, H., Filé, G. (eds.) SAS 2007. LNCS, vol. 4634, pp. 1–17. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  31. Tip, F., Kieżun, A., Bäumer, D.: Refactoring for generalization using type constraints. In: OOPSLA, pp. 13–26 (2003)

    Google Scholar 

  32. Torlak, E., Vaziri, M., Dolby, J.: MemSAT: Checking Axiomatic Specifications of Memory Models. In: PLDI 2010 (2010)

    Google Scholar 

  33. Watson, T.J.: Libraries for Analysis (WALA), http://wala.sf.net

  34. Wloka, J., Sridharan, M., Tip, F.: Refactoring for Reentrancy. In: ESEC/FSE (2009)

    Google Scholar 

  35. Zhao, J.: Multithreaded Dependence Graphs for Concurrent Java Program. In: Int. Symp. on Softw. Eng. for Parallel and Distr. Syst. (1999)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2010 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Schäfer, M., Dolby, J., Sridharan, M., Torlak, E., Tip, F. (2010). Correct Refactoring of Concurrent Java Code. In: D’Hondt, T. (eds) ECOOP 2010 – Object-Oriented Programming. ECOOP 2010. Lecture Notes in Computer Science, vol 6183. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-14107-2_11

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-14107-2_11

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-14106-5

  • Online ISBN: 978-3-642-14107-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics