Files in this item



application/pdfimmutator.pdf (476kB)
Main articlePDF


Title:Refactoring for Immutability
Author(s):Kjolstad, Fredrik Berg; Dig, Danny; Acevedo, Gabriel; Snir, Marc
refactoring tools
program analysis
program transformation
Abstract:It is common for Object-Oriented programs to contain mutable and immutable classes. Immutable classes simplify sequential programing because the programmer does not have to reason about side-effects. Immutable classes also simplify parallel programming because they are embarrassingly thread-safe. Sometimes programmers write immutable classes from scratch, other times they refactor mutable into immutable classes. To refactor a mutable class, programmers must find (i) all methods that mutate its transitive state and (ii) all objects that can enter or escape the state of the class. The programmer must also update client code to use the class in an immutable fashion. The analysis is non-trivial and the rewriting is tedious. Fortunately, this can be automated. We present Immutator, a technique and tool that enables the programmer to safely refactor a mutable class into an immutable class. Immutator also repairs client code to use the refactored class in an immutable fashion. Experience with refactoring several open-source programs shows that Immutator is useful: (i) it reduces the burden of making classes immutable, (ii) is fast enough to be used interactively, and (iii) is much safer than manual refactorings performed by open-source developers.
Issue Date:2010-06-07
Genre:Technical Report
Publication Status:unpublished
Peer Reviewed:is peer reviewed
Date Available in IDEALS:2010-06-07

This item appears in the following Collection(s)

Item Statistics