Reconciling Virtual Classes with Genericity

  • Erik Ernst
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4228)


Type abstraction in object-oriented languages mainly embodies two techniques with different strenghts and weaknesses. The first technique is extension, yielding abstraction mechanisms with good support for gradual specification; the prime example is inheritance. The second technique is functional abstraction, yielding more precise knowledge about the outcome; the prime example is type parameterized classes. This paper argues that they should be clearly separated to work optimally. We have applied this design philosophy to a language based on an extension mechanism, namely virtual classes. As a result, a kind of type parameters have been introduced, but they are simple and only used where they excel. Conversely, final definitions of virtual classes have been removed from the language, thus making virtual classes more flexible. The resulting language presents a clearer and more flexible trade-off between extensibility and predictability, empowering programmers to choose the right balance.


Virtual Object Parameterized Class Recursive Structure Type Argument Java Programming Language 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Bracha, G., Cook, W.: Mixin-based inheritance. In: Proceedings OOPSLA/ECOOP, ACM SIGPLAN Notices, vol. 25(10), pp. 303–311 (October 1990)Google Scholar
  2. 2.
    Bruce, K., Odersky, M., Wadler, P.: A statically safe alternative to virtual types. In: Jul, E. (ed.) ECOOP 1998. LNCS, vol. 1445, pp. 523–549. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  3. 3.
    Bruce, K.B., Van Gent, R., Schuett, A.: PolyTOIL: A type-safe polymorphic object-oriented language. In: Olthoff, W. (ed.) ECOOP 1995. LNCS, vol. 952, pp. 27–51. Springer, Heidelberg (1995)Google Scholar
  4. 4.
    Canning, P., Cook, W., Hill, W., Mitchell, J., Olthoff, W.: F-bounded polymorphism for object-oriented programming. In: Fourth International Conference on Functional Programming and Computer Architecture. ACM, New York (1989); Also technical report STL-89-5, from Software Technology Laboratory, Hewlett-Packard Laboratories (1989)Google Scholar
  5. 5.
    Ernst, E.: gbeta – A Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. Ph.D thesis, DEVISE, Department of Computer Science, University of Aarhus, Aarhus, Denmark (June 1999)Google Scholar
  6. 6.
    Ernst, E.: Family polymorphism. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 303–326. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  7. 7.
    Ernst, E.: Higher-order hierarchies. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 303–329. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  8. 8.
    Ernst, E., Ostermann, K., Cook, W.R.: A virtual class calculus. In: Proceedings POPL 2006, Charleston, SC, USA, pp. 270–282. ACM, New York (2006)Google Scholar
  9. 9.
    Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: Conference Record of POPL 1998: The 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, San Diego, California, January 19-21, pp. 171–183 (1998)Google Scholar
  10. 10.
    Girard, J.-Y.: Interprétation fonctionelle et élimination des coupures de l’arithmétique d’ordre supérieur. Ph.D thesis, Université Paris VII (1972); A summary appeared in: Fenstad, J.E.(ed.) Proceedings of the Second Scandinavian Logic Symposium ( editor), pp. 63–92. North-Holland (1971)Google Scholar
  11. 11.
    Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java Language Specification, 3rd edn. The Java Series. Addison-Wesley, Reading (2004)Google Scholar
  12. 12.
    Igarashi, A., Viroli, M.: On Variance-Based Subtyping for Parametric Types. In: Magnusson, B. (ed.) ECOOP 2002. LNCS, vol. 2374, pp. 441–469. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  13. 13.
    Madsen, O.L., Møller-Pedersen, B.: Virtual classes: A powerful mechanism in object-oriented programming. In: Proceedings OOPSLA (1989); ACM SIGPLAN Notices.  vol. 24(10), pp. 397–406 (October 1989)Google Scholar
  14. 14.
    Madsen, O.L., Møller-Pedersen, B., Nygaard, K.: Object-Oriented Programming in the BETA Programming Language. Addison Wesley, Reading (1993)Google Scholar
  15. 15.
    Mezini, M., Ostermann, K.: Conquering aspects with Caesar. In: Proceedings AOSD 2003, Boston, USA, pp. 90–99 (2003)Google Scholar
  16. 16.
    Microsoft Corporation, Seattle, USA. C# – Version 2.0 Specification (May 2004)Google Scholar
  17. 17.
    Milner, R., Tofte, M., Harper, R.W., MacQueen, D.: The Definition of Standard ML. MIT Press, Cambridge (1997)Google Scholar
  18. 18.
    Nystrom, N., Chong, S., Myers, A.C.: Scalable extensibility via nested inheritance. In: Proceedings OOPSLA 2004, pp. 99–115. ACM Press, New York (2004)CrossRefGoogle Scholar
  19. 19.
    Odersky, M., et al.: An overview of the scala programming language. Technical Report IC/2004/64, EPFL Lausanne, Switzerland (2004)Google Scholar
  20. 20.
    Odersky, M., Zenger, M.: Scalable component abstractions. In: Proceedings OOPSLA 2005, pp. 41–57. ACM Press, New York (2005)CrossRefGoogle Scholar
  21. 21.
    Ostermann, K.: Dynamically composable collaborations with delegation layers. In: Magnusson, B. (ed.) ECOOP 2002. LNCS, vol. 2374, pp. 89–110. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  22. 22.
    Strachey, C.: Fundamental concepts in programming languages. Lecture Notes, International Summer School in Programming Languages, Copenhagen, Denmark (1967)Google Scholar
  23. 23.
    Thorup, K.K., Torgersen, M.: Unifying genericity - combining the benefits of virtual types and parameterized classes. In: Guerraoui, R. (ed.) ECOOP 1999. LNCS, vol. 1628, pp. 186–204. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  24. 24.
    Torgersen, M.: The expression problem revisited – four new solutions using generics. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  25. 25.
    Torgersen, M., Ernst, E., Hansen, C.P., von der Ahé, P., Bracha, G., Gafter, N.: Adding wildcards to the java programming language. Journal of Object Technology 3(11) (2004),

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Erik Ernst
    • 1
  1. 1.Department of Computer ScienceUniversity of AarhusDenmark

Personalised recommendations