Abstract
Object-oriented languages define the identity of an object to be an address-based object identifier. The programmer may customize the notion of object identity by overriding the equals() and hashCode() methods following a specified contract. This customization often introduces latent errors, since the contract is unenforced and at times impossible to satisfy, and its implementation requires tedious and error-prone boilerplate code. Relation types are a programming model in which object identity is defined declaratively, obviating the need for equals() and hashCode() methods. This entails a stricter contract: identity never changes during an execution. We formalize the model as an adaptation of Featherweight Java, and implement it by extending Java with relation types. Experiments on a set of Java programs show that the majority of classes that override equals() can be refactored into relation types, and that most of the remainder are buggy or fragile.
This work has been supported in part by the Defense Advanced Research Projects Agency (DARPA) under contract No. NBCH30390004.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html
T. J. Watson Libraries for Analysis(December 2006), http://wala.sourceforge.net
Allen, E., Chase, D., Hallett, J., Luchangco, V., Maessen, J.-W., Ryu, S., Steele, G., Tobin-Hochstadt, S.:The Fortress language specification, http://research.sun.com/projects/plrg/fortress.pdf
Apache Jakarta Project. BCEL (December 2006), http://jakarta.apache.org/bcel/
Bacon, D.F.: Kava: A Java dialect with a uniform object model for lightweight classes. Concurrency—Practice and Experience 15(3–5), 185–206 (2003)
Baker, H.G.: Equal rights for functional objects or, the more things change, the more they are the same. OOPS Messenger 4(4), 2–27 (1993)
Bierman, G., Meijer, E., Schulte, W.: The essence of data access in Cω. In: Black, A.P. (ed.) ECOOP 2005. LNCS, vol. 3586, Springer, Heidelberg (2005)
Bierman, G., Parkinson, M.J., Pitts, A.M.MJ.: An imperative core calculus for Java and Java effects. Tech. Rep. 563, Computer Laboratory,University of Cambridge (April 2003)
Bierman, G.M., Wren, A.: First-class relationships in an object-oriented language. In: Black, A.P. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 262–286. Springer, Heidelberg (2005)
Birka, A., Ernst, M.D.: A practical type system and language for reference immutability. In: Proceedings of the 19th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications (OOPSLA’04), pp. 35–49. ACM Press, New York (2004)
Blackburn, S.M., Garner, R., Hoffman, C., Khan, A.M., McKinley, K.S., Bentzur, R., Diwan, A., Feinberg, D., Frampton, D., Guyer, S.Z., Hirzel, M., Hosking, A., Jump, M., Lee, H., Moss, J.E.B., Phansalkar, A., Stefanović, D., VanDrunen, T., von Dincklage, D., Wiedermann, B.: The DaCapo benchmarks: Java benchmarking development and analysis. In: Proceedings of the 21st annual ACM SIGPLAN conference on Object-Oriented Programing, Systems, Languages, and Applications (OOPSLA’06), Portland, OR, USA, oct 2006, ACM Press, New York (2006)
Bloch, J.: Effective Java, Programming Language Guide. Addison-Wesley, Reading (2001)
Boyland, J., Noble, J., Retert, W.: Capabilities for sharing: A generalisation of uniqueness and read-only. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 2–27. Springer, Heidelberg (2001)
Carriero, N., Gelernter, D.: Linda in context. Commun. ACM 32(4), 444–458 (1989)
Charles, P., Grothoff, C., Saraswat, V., Donawa, C., Kielstra, A., Ebcioglu, K., von Praun, C., Sarkar, V.: X10: an object-oriented approach to non-uniform cluster computing. In: Proceedings of the 20th annual ACM SIGPLAN conference on Object oriented programming, systems, languages, and applications (OOPSLA’05), San Diego, CA, USA, pp. 519–538. ACM Press, New York (2005)
Dolby, J., Chien, A.: An automatic object inlining optimization and its evaluation. ACM SIGPLAN Notices 35(5), 345–357 (2000)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns, Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading (1995)
Goto, E.: Monocopy and Associative Algorithms in an Extended Lisp. Tech. Rep. 74-03, Information Science Laboratory, University of Tokyo (1974)
Igarashi, A., Pierce, B.C, Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems 23(3), 396–450 (2001)
Kniesel, G., Theisen, D.: Jac – access right based encapsulation for Java. Software: Practice and Experience 31(6), 555–576 (2001)
Krall, A., Vitek, J.: On extending Java. In: Mössenböck, H. (ed.) JMLC 1997. LNCS, vol. 1204, Springer, Heidelberg (1997)
Meijer, E., Shulte, W.: Unifying tables, objects and documents. In: DB-COOL (2003)
Michie, D.: Memo functions and machine learning. Nature, 218, 19–22
Microsoft. C# Language Specification. Microsoft Press (2001)
Pechtchanski, I., Sarkar, V.: Immutability specification and its applications. In: Java Grande, pp. 202–211 (2002)
Petter, M.: Personal communication (October 2006)
Peyton-Jones, S., Launchbury, J.: Unboxed values as first class citizens. In: Functional Programming Languages and Computer Architecture. 5th ACM Conference, Berlin, Germany, ACM Press, New York (1991)
Porat, S., Biberstein, M., Koved, L., Mendelson, B.: Automatic detection of immutable fields in Java. In: CASCON (2000)
Tschantz, M.S., Ernst, M.D.: Javari: adding reference immutability to Java. In: Proceedings of the 20th annual ACM SIGPLAN conference on Object oriented programming, systems, languages, and applications (OOPSLA’05), pp. 211–230. ACM Press, New York (2005)
van Reeuwijk, C., Sips, H J.: Adding tuples to Java: a study in lightweight data structures. In: JGI’02 (2002)
Vaziri, M., Tip, F., Dolby, J.: Associating synchronization constraints with data in an object-oriented language. In: POPL ’06: Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 334–345. ACM Press, New York, NY, USA (2006)
Vaziri, M., Tip, F., Fink, S., Dolby, J.: Declarative object identity using relation types. Tech. rep. IBM Research (Forthcoming 2007)
Yelick, K., Semenzato, L., Pike, G., Miyamoto, C., Liblit, B.: abd Paul Hilfinger, A. K., Graham, S., Gay, D., Colella, P., and Aiken, A. Titanium: A high-performance Java dialect. Concurrency—Practice and Experience, Java Special Issue (1998)
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 2007 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Vaziri, M., Tip, F., Fink, S., Dolby, J. (2007). Declarative Object Identity Using Relation Types. In: Ernst, E. (eds) ECOOP 2007 – Object-Oriented Programming. ECOOP 2007. Lecture Notes in Computer Science, vol 4609. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-73589-2_4
Download citation
DOI: https://doi.org/10.1007/978-3-540-73589-2_4
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-73588-5
Online ISBN: 978-3-540-73589-2
eBook Packages: Computer ScienceComputer Science (R0)