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
Pagination75–84
Date or Month PublishedSeptember
Conference LocationDubrovnik, Croatia
AbstractA compiler-checked immutability guarantee provides useful documentation, facilitates reasoning, and enables optimizations. This paper presents \emphImmutability Generic Java (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 \textttMutable, \textttImmutable, or \textttReadOnly. IGJ guarantees both \emphreference immutability (only mutable references can mutate an object) and \emphobject immutability (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.
Downloadshttps://checkerframework.org/manual/#igj-checker IGJ implementation https://homes.cs.washington.edu/~mernst/pubs/immutability-generics-fse20... PDF
Citation KeyZibinPAAKE2007