skip to main content
research-article

JavaGI in the battlefield: practical experience with generalized interfaces

Published:04 October 2009Publication History
Skip Abstract Section

Abstract

Generalized interfaces are an extension of the interface concept found in object-oriented languages such as Java or C#. The extension is inspired by Haskell's type classes. It supports retroactive and type-conditional interface implementations, binary methods, symmetric multimethods, interfaces over families of types, and static interface methods.

This article reports practical experience with generalized interfaces as implemented in the JavaGI language. Several real-world case studies demonstrate how generalized interfaces provide solutions to extension and integration problems with components in binary form, how they make certain design patterns redundant, and how they eliminate various run-time errors. In each case study, the use of JavaGI results in elegant and highly readable code.

Furthermore, the article discusses the implementation of a compiler and a run-time system for JavaGI. Benchmarks show that our implementation offers acceptable performance.

References

  1. G. Baumgartner, M. Jansche, and K. Läufer. Half&half: Multiple dispatch and retroactive abstraction for Java. Technical Report OSU-CISRC-5/01-TR08, Revised 3/02, Ohio State University, 2002.Google ScholarGoogle Scholar
  2. S. M. Blackburn et al. The DaCapo benchmarks: Java benchmarking development and analysis. In OOPSLA'06 OOPSLA2006, pages 169--190. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. G. Bracha. Generics in the Java programming language. http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf, 2004.Google ScholarGoogle Scholar
  4. G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In OOPSLA'98 OOPSLA1998, pages 183--200. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. K. B. Bruce, L. Cardelli, G. Castagna, J. Eifrig, S. F. Smith, V. Trifonov, G. T. Leavens, and B. C. Pierce. On binary methods. Theory and Practice of Object Systems, 1(3):221--242, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. K. B. Bruce and J. N. Foster. LOOJ: Weaving LOOM into Java. In M. Odersky, editor, 18th ECOOP, volume 3086 of LNCS, pages 389--413, Oslo, Norway, 2004. Springer.Google ScholarGoogle Scholar
  7. N. Cameron, S. Drossopoulou, and E. Ernst. A model for Java with wildcards. In J. Vitek, editor, 22nd ECOOP, volume 5142 of LNCS, Paphos, Cyprus, 2008. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. M. T. Chakravarty, G. Keller, and S. Peyton Jones. Associated type synonyms. In B. C. Pierce, editor, Proc. ICFP 2005, pages 241--253, Tallinn, Estonia, 2005. ACM Press, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. M. M. T. Chakravarty, G. Keller, S. Peyton Jones, and S. Marlow. Associated types with class. In M. Abadi, editor, Proc. 32nd ACM Symp. POPL, pages 1--13, Long Beach, CA, USA, 2005. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C. Chambers. Object-oriented multi-methods in Cecil. In O. L. Madsen, editor, 6th ECOOP, volume 615 of LNCS, pages 33--56. Springer, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. C. Clifton, G. T. Leavens, C. Chambers, and T. Millstein. MultiJava: Modular open classes and symmetric multiple dispatch for Java. In Proc. 15th ACM Conf. OOPSLA, pages 130--145, Minneapolis, MN, USA, 2000. ACM Press, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. C. Clifton, T. Millstein, G. T. Leavens, and C. Chambers. MultiJava: Design rationale, compiler implementation, and applications. ACM TOPLAS, 28(3):517--575, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. dom4j. http://www.dom4j.org/, 2008.Google ScholarGoogle Scholar
  14. Eclipse Foundation. Eclipse compiler for Java. http://download.eclipse.org/eclipse/downloads/drops/R-3.4.1-20080911170%0/index.php, 2008.Google ScholarGoogle Scholar
  15. B. Emir, A. Kennedy, C. V. Russo, and D. Yu. Variance and generalized constraints for C# generics. In 20th ECOOP, volume 4067 of LNCS, pages 279--303, Nantes, France, 2006. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. E. Ernst. Family polymorphism. In J. L. Knudsen, editor, 15th ECOOP, volume 2072 of LNCS, pages 303--326, Budapest, Hungary, 2001. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. R. Garcia, J. Järvi, A. Lumsdaine, J. G. Siek, and J. Willcock. A comparative study of language support for generic programming. In OOPSLA'03, pages 115--134. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification. Addison-Wesley, 3rd edition, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. D. Gregor, J. Järvi, J. Siek, B. Stroustrup, G. Dos Reis, and A. Lumsdaine. Concepts: Linguistic support for generic programming in C++. In OOPSLA'06, pages 291--310. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. S. S. Huang, D. Zook, and Y. Smaragdakis. cJ: Enhancing Java with safe type conditions. In Proc. 6th AOSD, pages 185--198, Vancouver, BC, Canada, 2006. ACM Press, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. J. Hunter and B. McLaughlin. JDOM. http://www.jdom.org/, 2007.Google ScholarGoogle Scholar
  23. A. Igarashi, B. C. Pierce, and P. Wadler. Featherweight Java: a minimal core calculus for Java and GJ. ACM TOPLAS, 23(3):396--450, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Jaxen. http://jaxen.codehaus.org/, 2008.Google ScholarGoogle Scholar
  25. M. P. Jones. Type classes with functional dependencies. In G. Smolka, editor, Proc. 9th ESOP, volume 1782 of LNCS, pages 230--244, Berlin, Germany, 2000. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. J. Järvi, J. Willcock, and A. Lumsdaine. Associated types and constraint propagation for mainstream object-oriented generics. In Proc. 20th ACM Conf. OOPSLA, pages 1--19, New York, NY, USA, 2005. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. T. Lindholm and F. Yellin. The Java Virtual Machine Specification. Addison-Wesley, second edition, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. V. Litvinov. Contraint-based polymorphism in Cecil: Towards a practical and static type system. In OOPSLA'98, pages 388--411. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. R. Lämmel and K. Ostermann. Software extension and integration with type classes. In GPCE '06, pages 161--170, New York, NY, USA, 2006. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. M. Mezini and K. Ostermann. Integrating independent components with on-demand remodularization. In Proc. 17th ACM Conf. OOPSLA, pages 52--67, Seattle, WA, USA, 2002. ACM Press, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. T. Millstein, M. Reay, and C. Chambers. Relaxed MultiJava: Balancing extensibility and modular typechecking. In OOPSLA'03, pages 224--240. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. A. Moors, F. Piessens, and M. Odersky. Generics of a higher kind. In G. E. Harris, editor, Proc. 23rd ACM Conf. OOPSLA, pages 423--438, Nashville, TN, USA, 2008. ACM Press, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. N. Myers. A new and useful template technique: 'traits'. In S. B. Lippman, editor, C++ gems, pages 451--457. SIGS Publications, Inc., New York, NY, USA, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. M. Odersky. The Scala language specification version 2.7, 2008. Draft, http://www.scala-lang.org/docu/files/ScalaReference.pdf.Google ScholarGoogle Scholar
  35. OMG. Unified modelling language specification, version 1.5, 2003.Google ScholarGoogle Scholar
  36. Proc. 18th ACM Conf. OOPSLA, Anaheim, CA, USA, 2003. ACM Press, New York.Google ScholarGoogle Scholar
  37. Proc. 21th ACM Conf. OOPSLA, Portland, OR, USA, 2006. ACM Press, New York.Google ScholarGoogle Scholar
  38. Proc. 13th ACM Conf. OOPSLA, Vancouver, BC, Canada, 1998. ACM Press, New York.Google ScholarGoogle Scholar
  39. H. Ossher and P. Tarr. Using subject-oriented programming to overcome common problems in object-oriented software development/evolution. In Proc. 21th ICSE, pages 687--688, Los Angeles, CA, USA, 1999. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. S. Peyton Jones, editor. Haskell 98 Language and Libraries, The Revised Report. Cambridge University Press, 2003.Google ScholarGoogle Scholar
  41. S. Peyton Jones, M. Jones, and E. Meijer. Type classes: An exploration of the design space. In J. Launchbury, editor, Proc. of the Haskell Workshop, Amsterdam, The Netherlands, 1997.Google ScholarGoogle Scholar
  42. A. Shalit. The Dylan Reference Manual: The Definitive Guide to the New Object-Oriented Programming Language. Addison-Wesley, Reading, MA, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. G. Steele. Common LISP: The Language. Digital Press, Bedford, MA, 2nd edition, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. P. Thiemann. An embedded domain-specific language for type-safe server-side Web-scripting. ACM TOIT, 5(1):1--46, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. M. Torgersen, E. Ernst, C. P. Hansen, P. von der Ahé, G. Bracha, and N. Gafter. Adding wildcards to the Java programming language. Journal of Object Technology, 3(11):97--116, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  46. P. Wadler. The expression problem, 1998. Posted on Java Genericity mailing list.Google ScholarGoogle Scholar
  47. P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad-hoc. In Proc. 16th ACM Symp. POPL, pages 60--76, Austin, Texas, USA, 1989. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. A. Warth, M. Stanojevic, and T. Millstein. Statically scoped object adaptation with expanders. In OOPSLA'06, pages 37--56. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. S. Wehr. Formalizing CoreGI. Technical Report 248, Universitat Freiburg, 2009. ftp://ftp.informatik.uni-freiburg.de/documents/reports/report248/report%00248.ps.gz.Google ScholarGoogle Scholar
  50. S. Wehr. Javagi homepage. http://www.informatik.uni-freiburg.de/ wehr/javagi, 2009.Google ScholarGoogle Scholar
  51. S. Wehr, R. Lämmel, and P. Thiemann. JavaGI: Generalized interfaces for Java. In E. Ernst, editor, 21st ECOOP, volume 4609 of LNCS, pages 347--372, Berlin, Germany, 2007. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. S. Wehr and P. Thiemann. Subtyping existential types. In 10th FTfJP, \textrminformal proceedings, 2008. http://www.informatik.uni-freiburg.de/ wehr/publications/subex.pdf.Google ScholarGoogle Scholar
  53. S. Wehr and P. Thiemann. JavaGI in the battlefield: Practical experience with generalized interfaces (extended version). Technical Report 247, Universitat Freiburg, 2009. ftp://ftp.informatik.uni-freiburg.de/documents/reports/report247/report%00247.ps.gz.Google ScholarGoogle Scholar
  54. XML path language (XPath) version 1.0. http://www.w3.org/TR/xpath, 1999.Google ScholarGoogle Scholar
  55. D. Yu, A. Kennedy, and D. Syme. Formalization of generics for the .NET common language runtime. In X. Leroy, editor, Proc. 31st ACM Symp. POPL, pages 39--51, Venice, Italy, 2004. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. JavaGI in the battlefield: practical experience with generalized interfaces

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 45, Issue 2
        GPCE '09
        February 2010
        182 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1837852
        Issue’s Table of Contents
        • cover image ACM Conferences
          GPCE '09: Proceedings of the eighth international conference on Generative programming and component engineering
          October 2009
          194 pages
          ISBN:9781605584942
          DOI:10.1145/1621607
          • General Chair:
          • Jeremy Siek,
          • Program Chair:
          • Bernd Fischer

        Copyright © 2009 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 4 October 2009

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader