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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Apache Ant, http://ant.apache.org
Balaban, I., Tip, F., Fuhrer, R.: Refactoring support for class library migration. In: OOPSLA, pp. 265–279 (2005)
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)
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)
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)
Cheng, J.: Slicing Concurrent Programs: A Graph-Theoretical Approach. In: Fritzson, P.A. (ed.) AADEBUG 1993. LNCS, vol. 749. Springer, Heidelberg (1993)
Dig, D., Marrero, J., Ernst, M.D.: Refactoring sequential Java code for concurrency via concurrent libraries. In: ICSE, pp. 397–407 (2009)
Dig, D., Tarce, M., Radoi, C., Minea, M., Johnson, R.: RELOOPER: Refactoring for Loop Parallelism in Java. In: OOPSLA Companion (2009)
Ekman, T., Hedin, G.: The JastAdd Extensible Java Compiler. SIGPLAN Notices 42(10), 1–18 (2007)
Ekman, T., Hedin, G.: The JastAdd system — modular extensible compiler construction. Science of Computer Programming 69(1-3), 14–26 (2007)
Fowler, M.: Refactoring. Improving the Design of Existing Code. Addison-Wesley, Reading (1999)
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)
Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java Language Specification, 3rd edn. PrenticeHall, Englewood Cliffs (2005)
Griswold, W.G.: Program Restructuring as an Aid to Software Maintenance. Ph.D. thesis, University of Washington (1991)
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)
Š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)
Kegel, H., Steimann, F.: Systematically Refactoring Inheritance to Delegation in Java. In: ICSE, pp. 431–440 (2008)
Kieżun, A., Ernst, M., Tip, F., Fuhrer, R.: Refactoring for parameterizing Java classes. In: ICSE, pp. 437–446 (2007)
Krinke, J.: Static Slicing of Threaded Programs. SIGPLAN Not. 33(7) (1998)
Lamport, L.: Time, clocks, and the ordering of events in a distributed system. ACM Commun. 21(7), 558–565 (1978)
Lea, D.: The JSR-133 Cookbook for Compiler Writers (2008), http://gee.cs.oswego.edu/dl/jmm/cookbook.html
Manson, J., Pugh, W., Adve, S.V.: The Java Memory Model. In: POPL, pp. 378–391. ACM, New York (2005)
Markstrum, S., Fuhrer, R.M., Millstein, T.D.: Towards concurrency refactoring for X10. In: PPOPP, pp. 303–304 (2009)
Naik, M., Aiken, A.: Conditional must not aliasing for static race detection. In: POPL. ACM Press, New York (2007)
Nilsson-Nyman, E., Ekman, T., Hedin, G., Magnusson, E.: Declarative Intraprocedural Flow Analysis of Java Source Code. In: LDTA (2008)
Opdyke, W.F.: Refactoring Object-Oriented Frameworks. PhD thesis, University Of Illinois at Urbana-Champaign (1992)
Schäfer, M., Ekman, T., de Moor, O.: Sound and Extensible Renaming for Java. In: Kiczales, G. (ed.) OOPSLA. 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: Drossopoulou, S. (ed.) ECOOP 2009 – Object-Oriented Programming. LNCS, vol. 5653, pp. 369–393. Springer, Heidelberg (2009)
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)
Tip, F.: Refactoring using type constraints. In: Riis Nielson, H., Filé, G. (eds.) SAS 2007. LNCS, vol. 4634, pp. 1–17. Springer, Heidelberg (2007)
Tip, F., Kieżun, A., Bäumer, D.: Refactoring for generalization using type constraints. In: OOPSLA, pp. 13–26 (2003)
Torlak, E., Vaziri, M., Dolby, J.: MemSAT: Checking Axiomatic Specifications of Memory Models. In: PLDI 2010 (2010)
Watson, T.J.: Libraries for Analysis (WALA), http://wala.sf.net
Wloka, J., Sridharan, M., Tip, F.: Refactoring for Reentrancy. In: ESEC/FSE (2009)
Zhao, J.: Multithreaded Dependence Graphs for Concurrent Java Program. In: Int. Symp. on Softw. Eng. for Parallel and Distr. Syst. (1999)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)