Skip to main content

Understanding the Impact of Collection Contracts on Design

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 6141))

Abstract

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.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Nelson, S., Pearce, D.J., Noble, J.: Understanding the impact of collection contracts on design. Technical Report 10-09, School of Engineering and Computer Science, Victoria University of Wellington, New Zealand (2010)

    Google Scholar 

  2. Chan, P., Lee, R.: The Java Class Libraries, 2nd edn., vol. 1. Addison-Wesley, Reading (1999)

    Google Scholar 

  3. Hovemeyer, D., Pugh, W.: Finding bugs is easy. In: OOPSLA Companion (2004)

    Google Scholar 

  4. Qualitas Research Group: Qualitas corpus release 20080603. The University of Auckland (2008), http://www.cs.auckland.ac.nz/~ewan/corpus/

  5. Khoshafian, S.N., Copeland, G.P.: Object identity. In: Proc. OOPSLA (1986)

    Google Scholar 

  6. Birtwistle, G.M., Dahl, O.J., Myhrhaug, B., Nygaard, K.: Simula Begin. Studentlitteratur (1979)

    Google Scholar 

  7. Goldberg, A., Robson, D.: Smalltalk-80: The Language and its Implementation. Addison-Wesley, Reading (1983)

    MATH  Google Scholar 

  8. MacLennan, B.J.: Values and objects in programming languages. SIGPLAN Notices 17(12), 70–79 (1982)

    Article  MathSciNet  Google Scholar 

  9. Baker, H.G.: Equal rights for functional objects or, the more things change, the more they are the same. In: OOPS Messenger, vol. 4(4) (1993)

    Google Scholar 

  10. Steele, G.L.: Common Lisp the Language, 2nd edn. Digital Press (1990)

    Google Scholar 

  11. Grogono, P., Sakkinen, M.: Copying and comparing: Problems and solutions. In: Bertino, E. (ed.) ECOOP 2000. LNCS, vol. 1850, pp. 226–250. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  12. Vaziri, M., Tip, F., Fink, S., Dolby, J.: Declarative object identity using relation types. In: Ernst, E. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 54–78. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  13. Rupakheti, C.R., Hou, D.: An empirical study of the design and implementation of object equality in Java. In: Proc. CASCON, p. 9 (2008)

    Google Scholar 

  14. Liskov, B., Guttag, J.V.: Abstraction and Specification in Program Development. MIT Press/McGraw-Hill (1986)

    Google Scholar 

  15. Odersky, M.: Programming in Scala. Artima, Inc. (2008)

    Google Scholar 

  16. Zibin, Y., Potanin, A., Ali, M., Artzi, S., Kiezun, A., Ernst, M.D.: Object and reference immutability using Java generics. In: ESEC/SIGSOFT FSE, pp. 75–84 (2007)

    Google Scholar 

  17. Östlund, J., Wrigstad, T., Clarke, D., Åkerblom, B.: Ownership, uniqueness, and immutability. In: TOOLS, vol. (46), pp. 178–197 (2008)

    Google Scholar 

  18. Fähndrich, M., Xia, S.: Establishing object invariants with delayed types. In: Proc. OOPSLA, pp. 337–350 (2007)

    Google Scholar 

  19. Haack, C., Poll, E.: Type-based object immutability with flexible initialization. Technical Report ICIS-R09001, Radboud University Nijmegen (January 2009)

    Google Scholar 

  20. Leino, K.R.M., Müller, P., Wallenburg, A.: Flexible immutability with frozen objects. In: VSTTE, pp. 192–208 (2008)

    Google Scholar 

  21. Qi, X., Myers, A.C.: Masked types for sound object initialization. In: POPL, pp. 53–65 (2009)

    Google Scholar 

  22. Gil, J., Shragai, T.: Are we ready for a safer construction environment? In: Drossopoulou, S. (ed.) ECOOP 2009 – Object-Oriented Programming. LNCS, vol. 5653, pp. 495–519. Springer, Heidelberg (to appear, 2009)

    Chapter  Google Scholar 

  23. Unkel, C., Lam, M.S.: Automatic inference of stationary fields: a generalization of Java’s final fields. In: POPL, pp. 183–195 (2008)

    Google Scholar 

  24. Porat, S., Biberstein, M., Koved, L., Mendelson, B.: Automatic detection of immutable fields in Java. In: Proc. CASCON (1990)

    Google Scholar 

  25. Bloch, J.: Effective Java. Prentice Hall PTR, Englewood Cliffs (2008)

    Google Scholar 

  26. Cheng, P., Harper, R., Lee, P.: Generational stack collection and profile-driven pretenuring. In: Proc. of the ACM Conference on Programming Language Design and Implementation, pp. 162–173. ACM Press, New York (1998)

    Google Scholar 

  27. Agesen, O., Garthwaite, A.: Efficient object sampling via weak references. In: Proc. ISMM, pp. 121–126. ACM Press, New York (2000)

    Chapter  Google Scholar 

  28. Jump, M., Blackburn, S.M., McKinley, K.S.: Dynamic object sampling for pretenuring. In: Diwan, A. (ed.) Proc. ISMM. ACM Press, New York (2004)

    Google Scholar 

  29. Singer, J., Brown, G., Lujan, M., Watson, I.: Towards intelligent analysis techniques for object pretenuring. In: Principles and Practice of Programming in Java, Lisbon, September 2007. ACM Press, New York (2007)

    Google Scholar 

  30. Hirzel, M., Henkel, J., Diwan, A., Hind, M.: Understanding the connectivity of heap objects. In: Proc. ISMM, pp. 143–156 (2002)

    Google Scholar 

  31. Inoue, H., Stefanovic, D., Forrest, S.: On the prediction of Java object lifetimes. IEEE Trans. Computers 55(7), 880–892 (2006)

    Article  Google Scholar 

  32. Chen, G., Kandemir, M., Vijaykrishnan, N., Irwin, M.J.: Field level analysis for heap space optimization in embedded Java environments. In: Diwan, A. (ed.) ISMM’04 Proc. of the Fourth International Symposium on Memory Management, Vancouver, October 2004. ACM Press, New York (2004)

    Google Scholar 

  33. Guo, Z., Amaral, J.N., Szafron, D., Wang, Y.: Utilizing field usage patterns for java heap space optimization. In: Proc. of the conference of the Centre for Advanced Studies on Collaborative Research, pp. 67–79. IBM (2006)

    Google Scholar 

  34. Shankar, A., Arnold, M., Bodik, R.: Jolt: Lightweight dynamic analysis and removal of object churn. In: Proc. OOPSLA, pp. 127–142. ACM Press, New York (2008)

    Google Scholar 

  35. Dieckman, S., Hoelzle, U.: A study of the allocation behavior of the SPECjvm98 Java benchmarks. In: Guerraoui, R. (ed.) ECOOP 1999. LNCS, vol. 1628, pp. 92–115. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  36. Pearce, D.J., Webster, M., Berry, R., Kelly, P.H.J.: Profiling with AspectJ. Software: Pracice and Experience 37(7), 747–777 (2007)

    Article  Google Scholar 

  37. Röjemo, N., Runciman, C.: Lag, drag, void and use | heap profiling and space-efficient compilation revisited. In: Proc. ICFP, pp. 34–41. ACM Press, New York (1996)

    Google Scholar 

  38. Shaham, R., Kolodner, E.K., Sagiv, M.: Heap profiling for space-efficient Java. In: Proc. PLDI, pp. 104–113. ACM Press, New York (2001)

    Google Scholar 

  39. Marinov, D., O’Callahan, R.: Object equality profiling. SIGPLAN Not. 38(11), 313–325 (2003)

    Article  Google Scholar 

  40. Mitchell, N.: The runtime structure of object ownership. In: Thomas, D. (ed.) ECOOP 2006. LNCS, vol. 4067, pp. 74–98. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  41. Liang, S., Viswanathan, D.: Comprehensive profiling support in the Java Virtual Machine. In: Proc. of the USENIX Conference On Object Oriented Technologies and Systems, pp. 229–240. USENIX Association (1999)

    Google Scholar 

  42. Potanin, A., Noble, J., Frean, M.R., Biddle, R.: Scale-free geometry in OO programs. Communications of the ACM 48(5), 99–103 (2005)

    Article  Google Scholar 

  43. Orwell, G.: Animal Farm. Secker & Warburg (1945)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2010 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Nelson, S., Pearce, D.J., Noble, J. (2010). Understanding the Impact of Collection Contracts on Design. In: Vitek, J. (eds) Objects, Models, Components, Patterns. TOOLS 2010. Lecture Notes in Computer Science, vol 6141. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-13953-6_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-13953-6_4

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-13952-9

  • Online ISBN: 978-3-642-13953-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics