Understanding the Impact of Collection Contracts on Design

  • Stephen Nelson
  • David J. Pearce
  • James Noble
Part of the Lecture Notes in Computer Science book series (LNCS, 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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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. 2.
    Chan, P., Lee, R.: The Java Class Libraries, 2nd edn., vol. 1. Addison-Wesley, Reading (1999)Google Scholar
  3. 3.
    Hovemeyer, D., Pugh, W.: Finding bugs is easy. In: OOPSLA Companion (2004)Google Scholar
  4. 4.
    Qualitas Research Group: Qualitas corpus release 20080603. The University of Auckland (2008), http://www.cs.auckland.ac.nz/~ewan/corpus/
  5. 5.
    Khoshafian, S.N., Copeland, G.P.: Object identity. In: Proc. OOPSLA (1986)Google Scholar
  6. 6.
    Birtwistle, G.M., Dahl, O.J., Myhrhaug, B., Nygaard, K.: Simula Begin. Studentlitteratur (1979)Google Scholar
  7. 7.
    Goldberg, A., Robson, D.: Smalltalk-80: The Language and its Implementation. Addison-Wesley, Reading (1983)MATHGoogle Scholar
  8. 8.
    MacLennan, B.J.: Values and objects in programming languages. SIGPLAN Notices 17(12), 70–79 (1982)CrossRefMathSciNetGoogle Scholar
  9. 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. 10.
    Steele, G.L.: Common Lisp the Language, 2nd edn. Digital Press (1990)Google Scholar
  11. 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)CrossRefGoogle Scholar
  12. 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)CrossRefGoogle Scholar
  13. 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. 14.
    Liskov, B., Guttag, J.V.: Abstraction and Specification in Program Development. MIT Press/McGraw-Hill (1986)Google Scholar
  15. 15.
    Odersky, M.: Programming in Scala. Artima, Inc. (2008)Google Scholar
  16. 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. 17.
    Östlund, J., Wrigstad, T., Clarke, D., Åkerblom, B.: Ownership, uniqueness, and immutability. In: TOOLS, vol. (46), pp. 178–197 (2008)Google Scholar
  18. 18.
    Fähndrich, M., Xia, S.: Establishing object invariants with delayed types. In: Proc. OOPSLA, pp. 337–350 (2007)Google Scholar
  19. 19.
    Haack, C., Poll, E.: Type-based object immutability with flexible initialization. Technical Report ICIS-R09001, Radboud University Nijmegen (January 2009)Google Scholar
  20. 20.
    Leino, K.R.M., Müller, P., Wallenburg, A.: Flexible immutability with frozen objects. In: VSTTE, pp. 192–208 (2008)Google Scholar
  21. 21.
    Qi, X., Myers, A.C.: Masked types for sound object initialization. In: POPL, pp. 53–65 (2009)Google Scholar
  22. 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)CrossRefGoogle Scholar
  23. 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. 24.
    Porat, S., Biberstein, M., Koved, L., Mendelson, B.: Automatic detection of immutable fields in Java. In: Proc. CASCON (1990)Google Scholar
  25. 25.
    Bloch, J.: Effective Java. Prentice Hall PTR, Englewood Cliffs (2008)Google Scholar
  26. 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. 27.
    Agesen, O., Garthwaite, A.: Efficient object sampling via weak references. In: Proc. ISMM, pp. 121–126. ACM Press, New York (2000)CrossRefGoogle Scholar
  28. 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. 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. 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. 31.
    Inoue, H., Stefanovic, D., Forrest, S.: On the prediction of Java object lifetimes. IEEE Trans. Computers 55(7), 880–892 (2006)CrossRefGoogle Scholar
  32. 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. 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. 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. 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)CrossRefGoogle Scholar
  36. 36.
    Pearce, D.J., Webster, M., Berry, R., Kelly, P.H.J.: Profiling with AspectJ. Software: Pracice and Experience 37(7), 747–777 (2007)CrossRefGoogle Scholar
  37. 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. 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. 39.
    Marinov, D., O’Callahan, R.: Object equality profiling. SIGPLAN Not. 38(11), 313–325 (2003)CrossRefGoogle Scholar
  40. 40.
    Mitchell, N.: The runtime structure of object ownership. In: Thomas, D. (ed.) ECOOP 2006. LNCS, vol. 4067, pp. 74–98. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  41. 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. 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)CrossRefGoogle Scholar
  43. 43.
    Orwell, G.: Animal Farm. Secker & Warburg (1945)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Stephen Nelson
    • 1
  • David J. Pearce
    • 1
  • James Noble
    • 1
  1. 1.Victoria University of WellingtonWellingtonNew Zealand

Personalised recommendations