Object and reference immutability using Java generics

TitleObject and reference immutability using Java generics
Publication TypeConference Paper
Year of Publication2007
AuthorsZibin Y, Potanin A, Ali M, Artzi S, Kieżun A, Ernst MD
Conference NameESEC/FSE 2007: Proceedings of the 11th European Software Engineering Conference and the 15th ACM SIGSOFT Symposium on the Foundations of Software Engineering
Date or Month PublishedSeptember 5–7
Conference LocationDubrovnik, Croatia
Abstract<p>A compiler-checked immutability guarantee provides useful documentation, facilitates reasoning, and enables optimizations. This paper presents <em>Immutability Generic Java</em> (IGJ), a novel language extension that expresses immutability without changing Java's syntax by building upon Java's generics and annotation mechanisms. In IGJ, each class has one additional type parameter that is <tt>Mutable</tt>, <tt>Immutable</tt>, or <tt>ReadOnly</tt>. IGJ guarantees both <em>reference immutability</em> (only mutable references can mutate an object) and <em>object immutability</em> (an immutable reference points to an immutable object). IGJ is the first proposal for enforcing object immutability within Java's syntax and type system, and its reference immutability is more expressive than previous work. IGJ also permits covariant changes of type parameters in a type-safe manner, e.g., a readonly list of integers is a subtype of a readonly list of numbers. IGJ extends Java's type system with a few simple rules. We formalize this type system and prove it sound. Our IGJ compiler works by type-erasure and generates byte-code that can be executed on any JVM without runtime penalty.</p>
DownloadsIGJ implementation PDF PostScript
Citation KeyZibinPAAKE2007
Last changed Mon, 2013-06-03 10:27