skip to main content
10.1145/1985793.1985803acmconferencesArticle/Chapter ViewAbstractPublication PagesicseConference Proceedingsconference-collections
research-article

Transformation for class immutability

Authors Info & Claims
Published:21 May 2011Publication History

ABSTRACT

It is common for object-oriented programs to have both mutable and immutable classes. Immutable classes simplify programing because the programmer does not have to reason about side-effects. Sometimes programmers write immutable classes from scratch, other times they transform mutable into immutable classes. To transform a mutable class, programmers must find all methods that mutate its transitive state and all objects that can enter or escape the state of the class. The analyses are non-trivial and the rewriting is tedious. Fortunately, this can be automated.

We present an algorithm and a tool, Immutator, that enables the programmer to safely transform a mutable class into an immutable class. Two case studies and one controlled experiment show that Immutator is useful. It (i) reduces the burden of making classes immutable, (ii) is fast enough to be used interactively, and (iii) is much safer than manual transformations.

References

  1. J. P. Banning. An efficient way to find the side effects of procedure calls and the aliases of variables. In POPL, pages 29--41, 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. D. Bäumer, D. Riehle, W. Siberski, C. Lilienthal, D. Megert, K.-H. Sylla, and H. Züllighoven. Want value objects in java? Technical report, 1998.Google ScholarGoogle Scholar
  3. J. Bloch. Effective Java: Programming Language Guide. Addison-Wesley, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J.-D. Choi, M. Gupta, M. Serrano, V. C. Sreedhar, and S. Midkiff. Escape analysis for java. In OOPSLA, pages 1--19, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. D. Dig, J. Marrero, and M. D. Ernst. Refactoring sequential java code for concurrency via concurrent libraries. In ICSE, pages 397--407, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. D. Dig, M. Tarce, C. Radoi, M. Minea, and R. Johnson. Relooper: refactoring for loop parallelism in Java. In OOPSLA, pages 793--794, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. J. J. Dolado, M. Harman, M. C. Otero, and L. Hu. An empirical investigation of the influence of a type of side effects on program comprehension. IEEE TSE, 29(7):665--670, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. B. Goetz, T. Peierls, J. Bloch, J. Bowbeer, D. Holmes, and D. Lea. Java Concurrency in Practice. Addison-Wesley, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. W. G. Griswold and D. Notkin. Automated assistance for program restructuring. ACM TOSEM, 2(3):228--269, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. R. Hickey. The clojure programming language. In DLS, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Java SE 6 API Specification. http://java.sun.com/javase/6/docs/api.Google ScholarGoogle Scholar
  13. D. Lea. Concurrent Programming In Java. Addison-Wesley, second edition, 2000.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. D. Marinov and R. O'Callahan. Object equality profiling. In OOPSLA, pages 313--325, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. W. F. Opdyke and R. E. Johnson. Refactoring: An aid in designing application frameworks and evolving object-oriented systems. In SOOPPA, pages 145--160, 1990.Google ScholarGoogle Scholar
  16. I. Pechtchanski and V. Sarkar. Immutability specification and its applications. In Java Grande, pages 202--211, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. D. Riehle. Value object. In PLOP, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. A. Rountev. Precise identification of side-effect-free methods in Java. In ICSM, pages 82--91, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. B. G. Ryder, W. Landi, P. Stocks, S. Zhang, and R. Altucher. A schema for interprocedural modification side-effect analysis with pointer aliasing. ACM TOPLAS, 23(2):105--186, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. A. Salcianu and M. C. Rinard. Purity and side effect analysis for java programs. In VMCAI, pages 199--215, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. M. Schäfer, M. Sridharan, J. Dolby, and F. Tip. Refactoring java programs for flexible locking. To appear in ICSE, 2011.Google ScholarGoogle Scholar
  22. M. S. Tschantz and M. D. Ernst. Javari: Adding reference immutability to Java. In OOPSLA, pages 211--230, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. T.J. Watson Libraries for Analysis (WALA). http://wala.sourceforge.net/wiki/index.php.Google ScholarGoogle Scholar
  24. J. Whaley and M. C. Rinard. Compositional pointer and escape analysis for java programs. In OOPSLA, pages 187--206, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. J. Wloka, M. Sridharan, and F. Tip. Refactoring for Reentrancy. In FSE, pages 173--182, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Y. Zibin, A. Potanin, M. Ali, S. Artzi, A. Kiezun, and M. D. Ernst. Object and Reference Immutability using Java Generics. In FSE, pages 75--84, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Transformation for class immutability

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Conferences
        ICSE '11: Proceedings of the 33rd International Conference on Software Engineering
        May 2011
        1258 pages
        ISBN:9781450304450
        DOI:10.1145/1985793

        Copyright © 2011 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 21 May 2011

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate276of1,856submissions,15%

        Upcoming Conference

        ICSE 2025

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader