Javari: adding reference immutability to Java

This paper describes a type system that is capable of expressing and enforcing immutability constraints. The specific constraint expressed is that the abstract state of the object to which an immutable reference refers cannot be modified using that reference. The abstract state is (part of) the transitively reachable state: that is, the state of the object and all state reachable from it by following references. The type system permits explicitly excluding fields from the abstract state of an object. For a statically type-safe language, the type system guarantees reference immutability. If the language is extended with immutability downcasts, then run-time checks enforce the reference immutability constraints.This research builds upon previous research in language support for reference immutability. Improvements that are new in this paper include distinguishing the notions of assignability and mutability; integration with Java 5's generic types and with multi-dimensional arrays; a mutability polymorphism approach to avoiding code duplication; type-safe support for reflection and serialization; and formal type rules and type soundness proof for a core calculus. Furthermore, it retains the valuable features of the previous dialect, including usability by humans (as evidenced by experience with 160,000 lines of Javari code) and interoperability with Java and existing JVMs.

[1]  Bilha Mendelson,et al.  Automatic detection of immutable fields in Java , 2000, CASCON.

[2]  Matthias Felleisen,et al.  Classes and mixins , 1998, POPL '98.

[3]  Guy L. Steele,et al.  Java Language Specification, Second Edition: The Java Series , 2000 .

[4]  Barbara G. Ryder,et al.  A schema for interprocedural modification side-effect analysis with pointer aliasing , 2001, TOPL.

[5]  Martin C. Rinard,et al.  Purity and Side Effect Analysis for Java Programs , 2005, VMCAI.

[6]  John Tang Boyland,et al.  Capabilities for Sharing: A Generalisation of Uniqueness and Read-Only , 2001, ECOOP.

[7]  Jens Palsberg,et al.  Type-based analysis and applications , 2001, PASTE '01.

[8]  Jingling Xue,et al.  Interprocedural Side-Effect Analysis and Optimisation in the Presence of Dynamic Class Loading , 2005, ACSC.

[9]  Alexander Aiken,et al.  Flow-sensitive type qualifiers , 2002, PLDI '02.

[10]  John D. Gannon An experimental evaluation of data type conventions , 1977, CACM.

[11]  Vivek Sarkar,et al.  Immutability specification and its applications , 2002, JGI '02.

[12]  John Tang Boyland,et al.  Checking Interference with Fractional Permissions , 2003, SAS.

[13]  Flemming Nielson,et al.  Type and Effect Systems , 1999, Correct System Design.

[14]  Robert E. Tarjan,et al.  Self-adjusting binary search trees , 1985, JACM.

[15]  James Gosling,et al.  The Java Language Specification, 3rd Edition , 2005 .

[16]  Adrian Birka Compiler-Enforced Immutability for the Java Language , 2003 .

[17]  Keith D. Cooper,et al.  Interprocedural side-effect analysis in linear time (with retrospective) , 1988, PLDI 1988.

[18]  Barbara G. Ryder,et al.  Parameterized object sensitivity for points-to and side-effect analyses for Java , 2002, ISSTA '02.

[19]  Dirk Theisen,et al.  JAC—Access right based encapsulation for Java , 2001, Softw. Pract. Exp..

[20]  Robin Milner,et al.  Definition of standard ML , 1990 .

[21]  Kathryn S. McKinley,et al.  Data flow analysis for software prefetching linked data structures in Java , 2001, Proceedings 2001 International Conference on Parallel Architectures and Compilation Techniques.

[22]  David K. Gifford,et al.  Polymorphic effect systems , 1988, POPL '88.

[23]  Bjarne Stroustrup,et al.  The C++ Programming Language: Special Edition , 2000 .

[24]  Scott Meyers Effective C++ CD , 1998 .

[25]  Walter F. Tichy,et al.  A Controlled Experiment to Assess the Benefits of Procedure Argument Type Checking , 1998, IEEE Trans. Software Eng..

[26]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[27]  Barbara G. Ryder,et al.  Practical Points-to Analysis for Programs Built with Libraries , 2000 .

[28]  James Noble,et al.  Simple Ownership Types for Object Containment , 2001, ECOOP.

[29]  Barbara G. Ryder,et al.  Points-to and Side-Effect Analyses for Programs Built with Precompiled Libraries , 2001, CC.

[30]  Alexander Aiken,et al.  Checking and inferring local non-aliasing , 2003, PLDI '03.

[31]  Ernst-Rüdiger Olderog,et al.  Correct System Design, Recent Insight and Advances, (to Hans Langmaack on the occasion of his retirement from his professorship at the University of Kiel) , 1999 .

[32]  Yang Meng Tan,et al.  LCLint: a tool for using specifications to check code , 1994, SIGSOFT '94.

[33]  Pierre Jouvelot,et al.  The type and effect discipline , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[34]  Alexander Aiken,et al.  A theory of type qualifiers , 1999, PLDI '99.

[35]  Philip Wadler,et al.  Linear Types can Change the World! , 1990, Programming Concepts and Methods.

[36]  Joshua J. Bloch Effective Java : programming language guide , 2001 .

[37]  Robert DeLine,et al.  Adoption and focus: practical linear types for imperative programming , 2002, PLDI '02.

[38]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 2001, TOPL.

[39]  Tobias Wrigstad,et al.  A mode system for read-only references in Java , 2001 .

[40]  Xavier Leroy The objective caml system release 3 , 2001 .

[41]  Michael D. Ernst,et al.  A practical type system and language for reference immutability , 2004, OOPSLA '04.

[42]  Liuba Shrira,et al.  Ownership types for object encapsulation , 2003, POPL '03.

[43]  David E. Evans,et al.  Static detection of dynamic memory errors , 1996, PLDI '96.

[44]  Ken Kennedy,et al.  Interprocedural side-effect analysis in linear time , 1988, PLDI '88.

[45]  John Tang Boyland,et al.  Why we should not add readonly to Java (yet) , 2006, J. Object Technol..

[46]  Craig Chambers,et al.  Alias annotations for program understanding , 2002, OOPSLA '02.

[47]  Chrislain Razafimahefa A Study Of Side-Effect Analyses For Java , 1999 .

[48]  Guy L. Steele,et al.  The Java Language Specification , 1996 .