Understanding the Impact of Collection Contracts on Design

Java provides a specification for a user-defined general purpose equivalence operator for objects, but collections such as Set have more stringent requirements. This inconsistency breaks polymorphism: programmers must take care to follow Set's contract rather than the more general Object contract if their object could enter a Set. We have dynamically profiled 30 Java applications to better understand the way programmers design their objects, to determine whether they program with collections in mind. Our results indicate that objects which enter collections behave very differently to objects which do not. Our findings should help developers understand the impact of design choices they make, and guide future language designers when adding support for collections and/or equality.

[1]  Peter Grogono,et al.  Copying and Comparing: Problems and Solutions , 2000, ECOOP.

[2]  Dave Clarke,et al.  Ownership, Uniqueness, and Immutability , 2008, TOOLS.

[3]  Frank Tip,et al.  Declarative Object Identity Using Relation Types , 2007, ECOOP.

[4]  Rachid Guerraoui,et al.  ECOOP’ 99 — Object-Oriented Programming , 1999, Lecture Notes in Computer Science.

[5]  Peter Lee,et al.  Generational stack collection and profile-driven pretenuring , 1998, PLDI.

[6]  Darko Marinov,et al.  Object equality profiling , 2003, OOPSLA.

[7]  Michael D. Ernst,et al.  Object and reference immutability using Java generics , 2007, ESEC-FSE '07.

[8]  Martin Odersky,et al.  Programming in Scala , 2008 .

[9]  Erik Poll,et al.  Type-based Object Immutability with Flexible Initialization - extended version , 2009 .

[10]  Henry G. Baker,et al.  Equal rights for functional objects or, the more things change, the more they are the same , 1993, OOPS.

[11]  Yang Wang,et al.  Utilizing field usage patterns for Java heap space optimization , 2006, CASCON.

[12]  Songtao Xia,et al.  Establishing object invariants with delayed types , 2007, OOPSLA.

[13]  Gavin Brown,et al.  Towards intelligent analysis techniques for object pretenuring , 2007, PPPJ.

[14]  Urs Hölzle,et al.  A Study of the Allocation Behavior of the SPECjvm98 Java Benchmark , 1999, ECOOP.

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

[16]  K. Rustan M. Leino,et al.  Flexible Immutability with Frozen Objects , 2008, VSTTE.

[17]  Sheng Liang,et al.  Comprehensive Profiling Support in the Java Virtual Machine , 1999, COOTS.

[18]  C MyersAndrew,et al.  Masked types for sound object initialization , 2009 .

[19]  O. J. Dahl,et al.  Simula Begin , 1979 .

[20]  Patrick Chan,et al.  The Java class libraries , 1998 .

[21]  Xin Qi,et al.  Masked types for sound object initialization , 2009, POPL '09.

[22]  Setrag Khoshafian,et al.  Object identity , 1986, OOPLSA '86.

[23]  Amer Diwan,et al.  Understanding the connectivity of heap objects , 2002, ISMM '02.

[24]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

[25]  James Noble,et al.  Scale-free geometry in OO programs , 2005, CACM.

[26]  V. Stavridou,et al.  Abstraction and specification in program development , 1988 .

[27]  Elliot K. Kolodner,et al.  Heap profiling for space-efficient Java , 2001, PLDI '01.

[28]  Erik Ernst,et al.  ECOOP 2007 - Object-Oriented Programming, 21st European Conference, Berlin, Germany, July 30 - August 3, 2007, Proceedings , 2007, ECOOP.

[29]  Mahmut T. Kandemir,et al.  Field level analysis for heap space optimization in embedded java environments , 2004, ISMM '04.

[30]  Daqing Hou,et al.  An empirical study of the design and implementation of object equality in Java , 2008, CASCON '08.

[31]  Sophia Drossopoulou ECOOP 2009 - Object-Oriented Programming, 23rd European Conference, Genoa, Italy, July 6-10, 2009. Proceedings , 2009, ECOOP.

[32]  Joseph Gil,et al.  Are We Ready for a Safer Construction Environment? , 2009, ECOOP.

[33]  Guy L. Steele,et al.  Common Lisp the Language , 1984 .

[34]  Nick Mitchell,et al.  The Runtime Structure of Object Ownership , 2006, ECOOP.

[35]  Alex Garthwaite,et al.  Efficient object sampling via weak references , 2000, ISMM '00.

[36]  Niklas Röjemo,et al.  Lag, drag, void and use—heap profiling and space-efficient compilation revisited , 1996, ICFP '96.

[37]  Dave Thomas,et al.  ECOOP 2006 - Object-Oriented Programming , 2006 .

[38]  Monica S. Lam,et al.  Automatic inference of stationary fields: a generalization of java's final fields , 2008, POPL '08.

[39]  Paul H. J. Kelly,et al.  Profiling with AspectJ , 2007, Softw. Pract. Exp..

[40]  Elisa Bertino,et al.  ECOOP 2000 — Object-Oriented Programming , 2000, Lecture Notes in Computer Science.

[41]  Matthew Arnold,et al.  Jolt: lightweight dynamic analysis and removal of object churn , 2008, OOPSLA.

[42]  Bruce J. MacLennan Values and objects in programming languages , 1982, SIGP.

[43]  Jr. Guy L. Steele,et al.  Common LISP: the language (2nd ed.) , 1990 .

[44]  Stephanie Forrest,et al.  On the prediction of Java object lifetimes , 2006, IEEE Transactions on Computers.

[45]  Kathryn S. McKinley,et al.  Dynamic object sampling for pretenuring , 2004, ISMM '04.

[46]  Patrick Chan,et al.  The Java Class Libraries, Second Edition, Volume 2 , 1998 .