FHJ: A Formal Model for Hierarchical Dispatching and Overriding

Authors Yanlin Wang, Haoyuan Zhang, Bruno C. d. S. Oliveira, Marco Servetto



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2018.20.pdf
  • Filesize: 0.76 MB
  • 30 pages

Document Identifiers

Author Details

Yanlin Wang
  • The University of Hong Kong, China
Haoyuan Zhang
  • The University of Hong Kong, China
Bruno C. d. S. Oliveira
  • The University of Hong Kong, China
Marco Servetto
  • Victoria University of Wellington, New Zealand

Cite AsGet BibTex

Yanlin Wang, Haoyuan Zhang, Bruno C. d. S. Oliveira, and Marco Servetto. FHJ: A Formal Model for Hierarchical Dispatching and Overriding. In 32nd European Conference on Object-Oriented Programming (ECOOP 2018). Leibniz International Proceedings in Informatics (LIPIcs), Volume 109, pp. 20:1-20:30, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2018)
https://doi.org/10.4230/LIPIcs.ECOOP.2018.20

Abstract

Multiple inheritance is a valuable feature for Object-Oriented Programming. However, it is also tricky to get right, as illustrated by the extensive literature on the topic. A key issue is the ambiguity arising from inheriting multiple parents, which can have conflicting methods. Numerous existing work provides solutions for conflicts which arise from diamond inheritance: i.e. conflicts that arise from implementations sharing a common ancestor. However, most mechanisms are inadequate to deal with unintentional method conflicts: conflicts which arise from two unrelated methods that happen to share the same name and signature. This paper presents a new model called Featherweight Hierarchical Java (FHJ) that deals with unintentional method conflicts. In our new model, which is partly inspired by C++, conflicting methods arising from unrelated methods can coexist in the same class, and hierarchical dispatching supports unambiguous lookups in the presence of such conflicting methods. To avoid ambiguity, hierarchical information is employed in method dispatching, which uses a combination of static and dynamic type information to choose the implementation of a method at run-time. Furthermore, unlike all existing inheritance models, our model supports hierarchical method overriding: that is, methods can be independently overridden along the multiple inheritance hierarchy. We give illustrative examples of our language and features and formalize FHJ as a minimal Featherweight-Java style calculus.

Subject Classification

ACM Subject Classification
  • Software and its engineering → Object oriented languages
Keywords
  • multiple inheritance
  • hierarchical dispatching
  • OOP
  • language design

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Eric Allen, Jonathan Bannet, and Robert Cartwright. A first-class approach to genericity. In Proceedings of the 18th Annual ACM SIGPLAN Conference on Object-oriented Programing, Systems, Languages, and Applications, OOPSLA '03, pages 96-114, New York, NY, USA, 2003. ACM. URL: http://dx.doi.org/10.1145/949305.949316.
  2. Davide Ancona, Giovanni Lagorio, and Elena Zucca. Jam - designing a java extension with mixins. ACM Trans. Program. Lang. Syst., 25(5):641-712, 2003. Google Scholar
  3. Viviana Bono, Jarek Kuśmierek, and Mauro Mulatero. Magda: A new language for modularity. In Proceedings of the 26th European Conference on Object-Oriented Programming, ECOOP'12, pages 560-588, Berlin, Heidelberg, 2012. Springer-Verlag. URL: http://dx.doi.org/10.1007/978-3-642-31057-7_25.
  4. Viviana Bono, Enrico Mensa, and Marco Naddeo. Trait-oriented programming in java 8. In PPPJ '14, 2014. Google Scholar
  5. Gilad Bracha and William Cook. Mixin-based inheritance. In OOPSLA/ECOOP '90, 1990. Google Scholar
  6. Craig Chambers, David Ungar, Bay-Wei Chang, and Urs Hölzle. Parents are shared parts of objects: Inheritance and encapsulation in self. Lisp Symb. Comput., 4(3), 1991. Google Scholar
  7. Steve Cook. Varieties of inheritance. In OOPSLA '87 Panel P2, 1987. Google Scholar
  8. Vincent Cremet, François Garillot, Sergueï Lenglet, and Martin Odersky. A core calculus for scala type checking. In MFCS '06, 2006. Google Scholar
  9. Stéphane Ducasse, Oscar Nierstrasz, Nathanael Schärli, Roel Wuyts, and Andrew P. Black. Traits: A mechanism for fine-grained reuse. ACM Trans. Program. Lang. Syst., 28(2):331-388, 2006. Google Scholar
  10. Margaret A Ellis and Bjarne Stroustrup. The annotated C++ reference manual. Addison-Wesley, 1990. Google Scholar
  11. Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. Classes and mixins. In POPL '98, 1998. Google Scholar
  12. Brian Goetz and Robert Field. Featherweight defenders: A formal model for virtual extension methods in java. http://cr.openjdk.java.net/~briangoetz/lambda/featherweight-defenders.pdf, 2012.
  13. James Hendler. Enhancement for multiple-inheritance. In OOPWORK '86, 1986. Google Scholar
  14. Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. Featherweight java: A minimal core calculus for java and gj. ACM Trans. Program. Lang. Syst., 23(3):396-450, 2001. Google Scholar
  15. Jaroslaw DM Kusmierek and Viviana Bono. Hygienic methods - introducing hygjava. Journal of Object Technology, 6(9):209-229, 2007. Google Scholar
  16. Luigi Liquori and Arnaud Spiwack. Feathertrait: A modest extension of featherweight java. ACM Trans. Program. Lang. Syst., 30(2):11, 2008. Google Scholar
  17. Donna Malayeri and Jonathan Aldrich. Cz: Multiple inheritance without diamonds. In OOPSLA '09, 2009. Google Scholar
  18. B Meyer. Eiffel: Programming for reusability and extendibility. SIGPLAN Not., 22(2), 1987. Google Scholar
  19. Microsoft. Csharp explicit interface member implementations document. https://msdn.microsoft.com/en-us/library/aa664591(v=vs.71).aspx, 2003.
  20. David A. Moon. Object-oriented programming with flavors. In OOPSLA '86, 1986. Google Scholar
  21. Nathaniel Nystrom, Stephen Chong, and Andrew C. Myers. Scalable extensibility via nested inheritance. In OOPSLA '04, 2004. Google Scholar
  22. Martin Odersky, Philippe Altherr, Vincent Cremet, Burak Emir, Sebastian Maneth, Stéphane Micheloud, Nikolay Mihaylov, Michel Schinz, Erik Stenman, and Matthias Zenger. An overview of the scala programming language. Technical report, École Polytechnique Fédérale de Lausanne 1015 Lausanne, Switzerland, 2004. Google Scholar
  23. G. Ramalingam and Harini Srinivasan. A member lookup algorithm for c++. In PLDI '97, 1997. Google Scholar
  24. Tahina Ramananandro. Mechanized Formal Semantics and Verified Compilation for C++ Objects. PhD thesis, Université Paris-Diderot-Paris VII, 2012. Google Scholar
  25. John Reppy and Aaron Turon. A foundation for trait-based metaprogramming. In FOOL/WOOD '06, 2006. Google Scholar
  26. John Reppy and Aaron Turon. Metaprogramming with traits. In ECOOP '07, 2007. Google Scholar
  27. Markku Sakkinen. Disciplined inheritance. In ECOOP '89, 1989. Google Scholar
  28. Nathanael Schärli, Stéphane Ducasse, Oscar Nierstrasz, and Andrew P. Black. Traits: Composable units of behaviour. In ECOOP '03, 2003. Google Scholar
  29. Ghan Bir Singh. Single versus multiple inheritance in object oriented programming. SIGPLAN OOPS Mess., 1995. Google Scholar
  30. Bjarne Stroustrup. The design and evolution of C++. Pearson Education India, 1994. Google Scholar
  31. Bjarne Stroustrup. The C++ programming language. Pearson Education India, 1995. Google Scholar
  32. Marc Van Limberghen and Tom Mens. Encapsulation and composition as orthogonal operators on mixins: A solution to multiple inheritance problems. Object Oriented Systems, 3(1):1-30, 1996. Google Scholar
  33. Yanlin Wang, Haoyuan Zhang, Bruno C. d. S. Oliveira, and Marco Servetto. Classless java. In GPCE '16, 2016. Google Scholar
  34. Daniel Wasserrab, Tobias Nipkow, Gregor Snelting, and Frank Tip. An operational semantics and type safety prooffor multiple inheritance in c++. In OOPSLA '06, 2006. Google Scholar
  35. A.K. Wright and M. Felleisen. A syntactic approach to type soundness. Inf. Comput., 115(1):38-94, 1994. Google Scholar
  36. Matthias Zenger and Martin Odersky. Independently extensible solutions to the expression problem. In FOOL '05, 2005. Google Scholar
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail