Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/1869459.1869509acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Ownership and immutability in generic Java

Published: 17 October 2010 Publication History

Abstract

The Java language lacks the important notions of ownership (an object owns its representation to prevent unwanted aliasing) and immutability (the division into mutable, immutable, and readonly data and references). Programmers are prone to design errors, such as representation exposure or violation of immutability contracts. This paper presents Ownership Immutability Generic Java (OIGJ), a backward-compatible purely-static language extension supporting ownership and immutability. We formally defined a core calculus for OIGJ, based on Featherweight Java, and proved it sound. We also implemented OIGJ and performed case studies on 33,000 lines of code.
Creation of immutable cyclic structures requires a "cooking phase" in which the structure is mutated but the outside world cannot observe this mutation. OIGJ uses ownership information to facilitate creation of immutable cyclic structures, by safely prolonging the cooking phase even after the constructor finishes.
OIGJ is easy for a programmer to use, and it is easy to implement (flow-insensitive, adding only 14 rules to those of Java). Yet, OIGJ is more expressive than previous ownership languages, in the sense that it can type-check more good code. OIGJ can express the factory and visitor patterns, and OIGJ can type-check Sun's java.util collections (except for the clone method) without refactoring and with only a small number of annotations. Previous work required major refactoring of existing code in order to fit its ownership restrictions. Forcing refactoring of well-designed code is undesirable because it costs programmer effort, degrades the design, and hinders adoption in the mainstream community.

References

[1]
}}Chandrasekhar Boyapati. SafeJava: A Unified Type System for Safe Programming. PhD thesis, MIT Dept. of EECS, Feb. 2004.
[2]
}}Chandrasekhar Boyapati, Robert Lee, and Martin Rinard. Ownership types for safe programming: Preventing data races and deadlocks. In OOPSLA, pages 211--230, Oct. 2002.
[3]
}}Chandrasekhar Boyapati, Barbara Liskov, and Liuba Shrira. Ownership types for object encapsulation. In POPL, pages 213--223, Jan. 2003.
[4]
}}John Boyland. Why we should not add readonly to Java (yet). In FTfJP, July 2005.
[5]
}}John Boyland, James Noble, and William Retert. Capabilities for sharing: A generalisation of uniqueness and read-only. In ECOOP, pages 2--27, June 2001.
[6]
}}John Boyland, William Retert, and Yang Zhao. Comprehending annotations on object-oriented programs using fractional permissions. In IWACO, pages 1--11, July 2009.
[7]
}}Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In OOPSLA, pages 183--200, Oct. 1998.
[8]
}}Nicholas Cameron and Sophia Drossopoulou. Existential quantification for variant ownership. In ESOP, pages 128--142, Mar. 2009.
[9]
}}Nicholas Cameron, Sophia Drossopoulou, and Erik Ernst. A model for Java with wildcards. In ECOOP, pages 2--26, July 2008.
[10]
}}Nicholas R. Cameron, Sophia Drossopoulou, James Noble, and Matthew J. Smith. Multiple ownership. In OOPSLA, pages 441--460, Oct. 2007.
[11]
}}Dave Clarke and Sophia Drossopoulou. Ownership, encapsulation and the disjointness of type and effect. In OOPSLA, pages 292--310, Oct. 2002.
[12]
}}Dave Clarke and Tobias Wrigstad. External uniqueness is unique enough. In ECOOP, pages 176--200, July 2003.
[13]
}}David G. Clarke, John M. Potter, and James Noble. Ownership types for flexible alias protection. In OOPSLA, pages 48--64, Oct. 1998.
[14]
}}Werner Dietl, Sophia Drossopoulou, and Peter Muller. Generic Universe Types. In ECOOP, pages 28--53, Aug. 2007.
[15]
}}Michael D. Ernst. Type Annotations specification (JSR 308). http://types.cs.washington.edu/jsr308/, Sep. 12, 2008.
[16]
}}Manuel Fahndrich and Songtao Xia. Establishing object invariants with delayed types. In OOPSLA, pages 337--350, Oct. 2007.
[17]
}}Erich Gamma, Richard Helm, Ralph E. Johnson, and John Vlissides. Design Patterns. Addison-Wesley, Reading, MA, 1995.
[18]
}}Christian Haack and Erik Poll. Type-based object immutability with flexible initialization. In ECOOP, pages 520--545, 2009.
[19]
}}Christian Haack, Erik Poll, Jan Schafer, and Aleksy Schubert. Immutable objects for a Java-like language. In ESOP, pages 347--362, Mar. 2007.
[20]
}}Shan Shan Huang, David Zook, and Yannis Smaragdakis. cJ: Enhancing Java with safe type conditions. In AOSD, pages 185--198, Mar. 2007.
[21]
}}Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. Featherweight Java: a minimal core calculus for Java and GJ. ACM TOPLAS, 23(3):396--450, May 2001. ISSN 0164-0925.
[22]
}}Gunter Kniesel and Dirk Theisen. JAC - access right based encapsulation for Java. Software: Practice and Experience, 31(6):555--576, 2001.
[23]
}}K. Rustan M. Leino, Peter Muller, and Angela Wallenburg. Flexible immutability with frozen objects. In VSTTE, pages 192--208, Oct. 2008.
[24]
}}P. Muller and A. Poetzsch-Heffter. Universes: A type system for controlling representation exposure. In Programming Languages and Fundamentals of Programming, pages 131--140, 1999.
[25]
}}Peter Muller and Arsenii Rudich. Ownership transfer in universe types. In OOPSLA, pages 461--478, Oct. 2007.
[26]
}}Stefan Nageli. Ownership in design patterns. Master's thesis, ETH Zurich, Zurich, Switzerland, Mar. 2006.
[27]
}}James Noble. Iterators and encapsulation. In TOOLS Pacific, pages 431--442, 2000.
[28]
}}James Noble, Jan Vitek, and John Potter. Flexible alias protection. In ECOOP, pages 158--185, July 1998.
[29]
}}Nathaniel Nystrom, Vijay Saraswat, Jens Palsberg, and Christian Grothoff. Constrained types for object-oriented languages. In OOPSLA, pages 457--474, Oct. 2008.
[30]
}}Johan Ostlund, Tobias Wrigstad, and Dave Clarke. Ownership, uniqueness and immutability. In Tools Europe, pages 178--197, 2008.
[31]
}}Matthew M. Papi, Mahmood Ali, Telmo Luis Correa Jr., Jeff H. Perkins, and Michael D. Ernst. Practical pluggable types for Java. In ISSTA, pages 201--212, July 2008.
[32]
}}Benjamin C. Pierce. Types and Programming Languages. MIT Press, 2002.
[33]
}}Alex Potanin, James Noble, Dave Clarke, and Robert Biddle. Generic Ownership for Generic Java. In OOPSLA, pages 311--324, Oct. 2006.
[34]
}}Mats Skoglund and Tobias Wrigstad. A mode system for read-only references in Java. In FTfJP, June 2001.
[35]
}}Matthew S. Tschantz and Michael D. Ernst. Javari: Adding reference immutability to Java. In OOPSLA, pages 211--230, Oct. 2005.
[36]
}}Jan Vitek and Boris Bokowski. Confined types. In OOPSLA, pages 82--96, Nov. 1999.
[37]
}}Tobias Wrigstad. Ownership-Based Alias Management. PhD thesis, Royal Institute of Technology, Sweden, May 2006.
[38]
}}Tobias Wrigstad and Dave Clarke. Existential owners for ownership types. J. Object Tech., 6(4):141--159, May-June 2007.
[39]
}}Yoav Zibin. Featherweight Ownership and Immutability Generic Java (FOIGJ). Technical Report 10-16, ECS, VUW, June 2010. http://ecs.victoria.ac.nz/Main/TechnicalReportSeries.
[40]
}}Yoav Zibin, Alex Potanin, Mahmood Ali, Shay Artzi, Adam Kiezun, and Michael D. Ernst. Object and reference immutability using Java generics. In ESEC/FSE, pages 75--84, Sep. 2007.
[41]
}}Yoav Zibin, Alex Potanin, Paley Li, Mahmood Ali, and Michael D. Ernst. OIGJ with owners as modifiers. Technical Report 10-15, ECS, VUW, January 2010.

Cited By

View all
  • (2024)Reference Counting Deeply Immutable Data Structures with Cycles: An Intellectual AbstractProceedings of the 2024 ACM SIGPLAN International Symposium on Memory Management10.1145/3652024.3665507(131-141)Online publication date: 20-Jun-2024
  • (2023)Pluggable Type Inference for Free2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)10.1109/ASE56229.2023.00186(1542-1554)Online publication date: 11-Sep-2023
  • (2021)A Method to Comprehend Feature Dependencies Based on Semi-Static Structures2021 IEEE International Conference on Software Maintenance and Evolution (ICSME)10.1109/ICSME52107.2021.00020(148-158)Online publication date: Sep-2021
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
OOPSLA '10: Proceedings of the ACM international conference on Object oriented programming systems languages and applications
October 2010
984 pages
ISBN:9781450302036
DOI:10.1145/1869459
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 45, Issue 10
    OOPSLA '10
    October 2010
    957 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1932682
    Issue’s Table of Contents
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 17 October 2010

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. immutability
  2. java
  3. ownership

Qualifiers

  • Research-article

Conference

SPLASH '10
Sponsor:

Acceptance Rates

Overall Acceptance Rate 268 of 1,244 submissions, 22%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)72
  • Downloads (Last 6 weeks)1
Reflects downloads up to 12 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Reference Counting Deeply Immutable Data Structures with Cycles: An Intellectual AbstractProceedings of the 2024 ACM SIGPLAN International Symposium on Memory Management10.1145/3652024.3665507(131-141)Online publication date: 20-Jun-2024
  • (2023)Pluggable Type Inference for Free2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)10.1109/ASE56229.2023.00186(1542-1554)Online publication date: 11-Sep-2023
  • (2021)A Method to Comprehend Feature Dependencies Based on Semi-Static Structures2021 IEEE International Conference on Software Maintenance and Evolution (ICSME)10.1109/ICSME52107.2021.00020(148-158)Online publication date: Sep-2021
  • (2019)A Syntactic Model of Mutation and AliasingElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.293.4293(39-55)Online publication date: 23-Apr-2019
  • (2018)A type and effect system for uniqueness and immutabilityProceedings of the 33rd Annual ACM Symposium on Applied Computing10.1145/3167132.3167245(1038-1045)Online publication date: 9-Apr-2018
  • (2017)Verifying Invariants of Lock-Free Data Structures with Rely-Guarantee and Refinement TypesACM Transactions on Programming Languages and Systems10.1145/306485039:3(1-54)Online publication date: 10-May-2017
  • (2016)Refinement types for TypeScriptACM SIGPLAN Notices10.1145/2980983.290811051:6(310-325)Online publication date: 2-Jun-2016
  • (2016)Inference and Checking of Object ImmutabilityProceedings of the 13th International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools10.1145/2972206.2972208(1-12)Online publication date: 29-Aug-2016
  • (2016)Refinement types for TypeScriptProceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/2908080.2908110(310-325)Online publication date: 2-Jun-2016
  • (2016)ThisType for Object-Oriented LanguagesACM Transactions on Programming Languages and Systems10.1145/288839238:3(1-66)Online publication date: 8-Apr-2016
  • Show More Cited By

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media