This Article 
   
 Share 
   
 Bibliographic References 
   
 Add to: 
 
Digg
Furl
Spurl
Blink
Simpy
Google
Del.icio.us
Y!MyWeb
 
 Search 
   
A Reflective Implementation of Java Multi-Methods
December 2004 (vol. 30 no. 12)
pp. 1055-1071
In Java, method implementations are chosen at runtime by late-binding with respect to the runtime class of just the receiver argument. However, in order to simplify many programming designs, late-binding with respect to the dynamic type of all arguments is sometimes desirable. This behavior, usually provided by multi-methods, is known as multipolymorphism. This paper presents a new multi-method implementation based on the standard Java reflection mechanism. Provided as a package, it does not require any language extension nor any virtual machine modification. The design issues of this reflective implementation are presented together with a new and simple multi-method dispatch algorithm that efficiently supports class loading at runtime. This implementation provides a practicable and fully portable multi-method solution.

[1] L.G. DeMichiel and R.P. Gabriel, “The Common Lisp Object System: An Overview,” Proc. European Conf. Object-Oriented Programming, pp. 151-170, June 1987.
[2] G. Kiczales, J.D. Rivieres, and D. Bobrow, The Art of the Metaobject Protocol. Cambridge, Mass.: MIT Press, 1991.
[3] C. Chambers, “Object-Oriented Multi-Methods in Cecil,” Proc. European Conf. Object-Oriented Programming, July 1992.
[4] J. Boyland and G. Castagna, “Parasitic Methods: An Implementation of Multi-Methods for Java,” Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 66-76, Oct. 1997.
[5] M. Kizub, “Kiev Language Specification,” July 1998, an extension of Java language that inherits Pizza features and provides Multi-Methods (http://forestro.comkiev/).
[6] T. Millstein and C. Chambers, “Modular Statically Typed Multi-Methods,” Proc. European Conf. Object-Oriented Programming, pp. 279-303, June 1999.
[7] C. Clifton, G.T. Leavens, C. Chambers, and T. Millstein, “Multi-Java: Modular Open Classes and Symmetric Multiple Dispatch,” Proc. Conf. Object-Oriented Programming Systems, Languages and Applications, Oct. 2000.
[8] C. Dutchyn, P. Lu, D. Szafron, S. Bromling, and W. Holst, “Multidispatch in the Java Virtual Machine Design and Implementation,” Proc. Conf. Object-Oriented Technologies and Systems, Jan. 2001.
[9] G. Baumgartner, M. Jansche, and K. Läufer, “Half & Half: Multiple Dispatch and Retroactive Abstraction for Java,” Technical Report OSU-CISRC-5/01-TR08, Dept. of Computer and Information Science, Ohio State Univ., Mar. 2002.
[10] K. Bruce, L. Cardelli, and G. Castagna, G.T. Leavens, and B. Pierce, “On Binary Methods,” Theory and Practice of Object Systems, vol. 1, no. 3, pp. 221-242, 1996.
[11] E. Gamma, R. Helm, R. Johnson, and J. Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1995.
[12] K.J. Lieberherr, Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns. Boston: PWS Publishing Company, 1996.
[13] R. Forax and G. Roussel, “Recursive Types and Pattern-Matching in Java,” Proc. First Int'l Symp. Generative and Component-Based Software Eng., Sept. 1999.
[14] M. Viroli and A. Natali, “Parametric Polymorphism in Java: An Approach to Translation Based on Reflective Features,” Proc. Conf. Object-Oriented Programming Systems, Languages and Applications, pp. 146-165, 2000.
[15] R. Pawlak, L. Seinturier, L. Duchien, and G. Florin, “JAC: A Flexible Solution for Aspect-Oriented Programming in Java,” Proc. Reflection '01 Conf., Sept. 2001.
[16] C. Chambers, “Object-Oriented Multi-Methods in Cecil,” Proc. European Conf. Object-Oriented Programming, pp. 33-56, 1992.
[17] E. Bruneton, R. Lenglet, and T. Coupaye, “ASM: A Code Manipulation Tool to Implement Adaptable Systems,” Adaptable and Extensible Component Systems, Nov. 2002.
[18] C. Pang, W. Holst, Y. Leontiev, and D. Szafron, “Multi-Method Dispatch Using Multiple Row Displacement,” Proc. European Conf. Object-Oriented Programming, pp. 304-328, June 1999.
[19] J. Gosling, B. Joy, G. Steele, and G. Bracha, The Java Language Specification, second ed. Addison-Wesley, 2000.
[20] O.-J. Dahl and B. Myrhaug, “Simula Implementation Guide,” Technical Report S 47, Norwegian Computing Center, Mar. 1973.
[21] B. Liskov, “Data Abstraction and Hierarchy,” SIGPLAN Notices, vol. 23, no. 5, May 1988.
[22] C. Grothoff, “Walkabout Revisited: The Runabout,” Proc. European Conf. Object-Oriented Programming, pp. 103-125, 2003.
[23] R. Agrawal, L. DeMichiel, and B. Lindsay, “Static Type-Checking of Multi-Methods,” Proc. Conf. Object-Oriented Programming Systems, Languages and Applications, pp. 113-128, Oct. 1991.
[24] F. Bourdoncle and S. Merz, “Type-Checking Higher-Order Polymorphic Multi-Methods,” Proc. Ann. Symp. Principles of Programming Languages, pp. 302-315, Jan. 1997.
[25] E. Amiel, O. Gruber, and E. Simon, “Optimizing Multi-Method Dispatch Using Compressed Dispatch Tables,” Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 244-258, Oct. 1994.
[26] E.A.E. Dujardin and E. Simon, “Fast Algorithms for Compressed Multi-Method Dispatch Table Generation,” ACM Trans. Programming Languages and Systems, vol. 20, no. 1, pp. 116-165, Jan. 1998.
[27] Y. Zibin and J.Y. Gil, “Fast Algorithm for Creating Space Efficient Dispatching Tables with Application to Multidispatching,” Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 142-160, 2002.
[28] W. Chen, V. Turau, and W. Klas, “Efficient Dynamic Look-Up Strategy for Multi-Methods,” Proc. European Conf. Object-Oriented Programming, 1994.
[29] E. Dujardin, “Efficient Dispatch of Multi-Methods in Constant Time Using Dispatch Trees,” Rapport de Recherche 2892, INRIA, 1996.
[30] R. Forax, E. Duris, and G. Roussel, “Java Multi-Method Framework,” Proc. TOOLS Pacific '00 Conf., Nov. 2000.
[31] J. Dean, G. DeFouw, D. Grove, V. Litvinov, and C. Chambers, “Vortex an Optimizing Compiler for Object-Oriented Languages,” Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 83-110, 1996.
[32] W. Holst, D. Szafron, Y. Leontiev, and C. Pang, “Multi-Method Dispatch Using Single-Receiver Projections,” Technical Report 98-03, Dept. of Computer Science, Univ. of Alberta, Edmonton, Canada, 1998.
[33] J. Palsberg and C.B. Jay, “The Essence of the Visitor Pattern,” Proc. Int'l Computer Software and Applications Conf., pp. 9-15, 1998.
[34] I. Attali, F. Chalaux, C. Courbis, P. Degenne, A. Fau, and D. Parigot, “SmartTools,” June 2000, cooperative project for Interactive Generic Tools (http://www-sop.inria.fr/oasis SmartTools /).

Index Terms:
Java, polymorphism, reflection, dynamic class loading.
Citation:
R?mi Forax, Etienne Duris, Gilles Roussel, "A Reflective Implementation of Java Multi-Methods," IEEE Transactions on Software Engineering, vol. 30, no. 12, pp. 1055-1071, Dec. 2004, doi:10.1109/TSE.2004.90
Usage of this product signifies your acceptance of the Terms of Use.