Polyglot: An Extensible Compiler Framework for Java

  • Nathaniel Nystrom
  • Michael R. Clarkson
  • Andrew C. Myers
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2622)


Polyglot is an extensible compiler framework that supports the easy creation of compilers for languages similar to Java, while avoiding code duplication. The Polyglot framework is useful for domain-specific languages, exploration of language design, and for simplified versions of Java for pedagogical use. We have used Polyglot to implement several major and minor modifications to Java; the cost of implementing language extensions scales well with the degree to which the language differs from Java. This paper focuses on the design choices in Polyglot that are important for making the framework usable and highly extensible. Polyglot source code is available.


Extension Object Language Extension Node Class Abstract Syntax Tree Java Compiler 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Martin Alt, Uwe Aβmann, and Hans van Someren. Cosy compiler phase embedding with the CoSy compiler model. In Peter A. Fritzson, editor, Proceedings of the 5th International Compiler Construction Conference (CC’94), volume 786 of Lecture Notes in Computer Science, pages 278–293, Edinburgh, UK, April 1994.Google Scholar
  2. 2.
    Jason Baker and Wilson C. Hsieh. Maya: Multiple-dispatch syntax extension in Java. In Proc. of theACMSIGPLAN’ 02 Conference on Programming Language Design and Implementation (PLDI), pages 270–281, Berlin, Germany, June 2002.Google Scholar
  3. 3.
    Don Batory, Bernie Lofaso, and Yannis Smaragdakis. JTS: tools for implementing domainspecific languages. In Proceedings Fifth International Conference on Software Reuse, pages 143–53, Victoria, BC, Canada, 1998. IEEE.Google Scholar
  4. 4.
    Gilad Bracha. The Programming Language Jigsaw: Mixins, Modularity and Multiple Inheritance. PhD thesis, University of Utah, 1992.Google Scholar
  5. 5.
    Craig Chambers. Object-oriented multi-methods in Cecil. In Ole Lehrmann Madsen, editor, Proceedings of the 6th European Conference on Object-Oriented Programming (ECOOP), volume 615, pages 33–56, Berlin, Heidelberg, NewYork, Tokyo, 1992. Springer-Verlag.Google Scholar
  6. 6.
    Curtis Clifton, Gary T. Leavens, Craig Chambers, and Todd Millstein. MultiJava: Modular open classes and symmetric multiple dispatch for Java. In OOPSLA 2000 Conference on Object-Oriented Programming, Systems, Languages, and Applications, Minneapolis, Minnesota, volume 35(10), pages 130–145, 2000.Google Scholar
  7. 7.
    Robert DeLine and Manuel Fähndrich. Enforcing high-level protocols in low-level software. In Proceedings of the ACM Conference on Programming Language Design and Implementation, pages 59–69, June 2001.Google Scholar
  8. 8.
    Dawson Engler, Benjamin Chelf, Andy Chou, and Seth Hallem. Checking system rules using system-specific, programmer-written compiler extensions. In Proceedings of Fourth Usenix Symposium on Operating Systems Design and Implementation, San Diego, California, October 2000.Google Scholar
  9. 9.
    Robert Bruce Findler, Cormac Flanagan, Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. DrScheme: A pedagogic programming environment for Scheme. In Proc. International Symposium on Programming Languages: Implementations, Logics, and Programs, pages 369–388, 1997.Google Scholar
  10. 10.
    Cormac Flanagan, K. Rustan M. Leino, Mark Lillibridge, Greg Nelson, James B. Saxe, and Raymie Stata. Extended static checking for Java. In Proc. of the ACM SIGPLAN’ 02 Conference on Programming Language Design and Implementation (PLDI), pages 234–245, Berlin, Germany, June 2002.Google Scholar
  11. 11.
    Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. Classes and mixins. In Conference Record ofPOPL98:The25THACMSIGPLAN-SIGACTSymposium on Principles of Programming Languages, San Diego, California, pages 171–183, New York, NY, 1998.Google Scholar
  12. 12.
    D. K. Frayne and Keith Playford. The Java syntactic extender (JSE). In Proceedings of the 2001 Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA’ 01), pages 31–42, Tampa, FL, USA, 2001.Google Scholar
  13. 13.
    Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. AddisonWesley, Reading, MA, 1994.Google Scholar
  14. 14.
    James Gosling, Bill Joy, and Guy Steele. The Java Language Specification. Addison-Wesley, August 1996. ISBN 0-201-63451-1.Google Scholar
  15. 15.
    Carl Gunter and John C. Mitchell, editors. Theoretical aspects of object-oriented programming. MIT Press, 1994.Google Scholar
  16. 16.
    Görel Hedin and Eva Magnusson. JastAdd-an aspect-oriented compiler construction system. Science of Computer Programming, 47(1):37–58, November 2002.CrossRefMathSciNetGoogle Scholar
  17. 17.
    Scott E. Hudson, Frank Flannery, C. Scott Ananian, Dan Wang, and Andrew Appel. CUP LALR parser generator for Java, 1996. Software release. Located at
  18. 18.
    Yuuji Ichisugi and Yves Roudier. The extensible Java preprocessor kit and a tiny data-parallel Java. In Proc. ISCOPE’ 97, LNCS 1343, pages 153–160. Springer, 1997.Google Scholar
  19. 19.
    Richard Kelsey, William Clinger, and Jonathan Rees (editors). Revised5 report on the algorithmic language Scheme. ACM SIGPLAN Notices, 33(9):26–76, October 1998. Available at
  20. 20.
    Gregor Kiczales, John Lamping, Anurag Mendhekar, Chris Maeda, Cristina Videira Lopes, Jean-Marc Loingtier, and John Irwin. Aspect-oriented programming. In Proceedings of 11th European Conference on Object-Oriented Programming (ECOOP’97), number 1241 in Lecture Notes in Computer Science, pages 220–242, Jyväskylä, Finland, June 1997. Springer-Verlag.Google Scholar
  21. 21.
    Joseph R. Kiniry and Elaine Cheong. JPP: A Java pre-processor. Technical Report CS-TR-98-15, California Institute of Technology, Pasadena, CA, September 1998.Google Scholar
  22. 22.
    Shriram Krishnamurthi, Matthias Felleisen, and Daniel P. Friedman. Synthesizing objectoriented and functional design to promote re-use. In Proc. ECOOP’ 98, pages 91–113, 1998.Google Scholar
  23. 23.
    Gary T. Leavens, K. Rustan M. Leino, Erik Poll, Clyde Ruby, and Bart Jacobs. JML: notations and tools supporting detailed design in Java. In OOPSLA 2000 Companion, pages 105–106, Minneapolis, Minnesota, 2000.Google Scholar
  24. 24.
    Jed Liu and Andrew C. Myers. JMatch: Abstract iterable pattern matching for Java. In Proc. 5th Int’l Symp. on Practical Aspects of Declarative Languages, New Orleans, LA, January 2003.Google Scholar
  25. 25.
    Todd Millstein, Colin Bleckner, and Craig Chambers. Modular typechecking for hierarchically extensible datatypes and functions. In Proc. 7th ACM SIGPLAN International Conference on Functional Programming (ICFP), pages 110–122, Philadelphia, PA, USA, October 2002.Google Scholar
  26. 26.
    Andrew C. Myers. JFlow: Practical mostly-static information flowcontrol. In Proc. 26thACM Symp. on Principles of Programming Languages (POPL), pages 228–241, San Antonio, TX, January 19991.Google Scholar
  27. 27.
    Andrew C. Myers, Joseph A. Bank, and Barbara Liskov. Parameterized types for Java. In Proc. 24th ACM Symp. on Principles of Programming Languages (POPL), pages 132–145, Paris, France, January 1997.Google Scholar
  28. 28.
    Martin Odersky and Philip Wadler. Pizza into Java: Translating theory into practice. In Proc. 24th ACM Symp. on Principles of Programming Languages (POPL), pages 146–159, Paris, France, January 1997.Google Scholar
  29. 29.
    Terence Parr and Russell Quong. ANTLR: A predicated-LL(k) parser generator. Journal of Software Practice and Experience, 25(7), 1995.Google Scholar
  30. 30.
    John C. Reynolds. User-defined types and procedural data structures as complementary approaches to data abstraction. In Stephen A. Schuman, editor, New Directions in Algorithmic Languages, pages 157–168. Institut de Recherche d’Informatique et d’Automatique, Le Chesnay, France, 1975. Reprinted in [15], pages 13–23.Google Scholar
  31. 31.
    Richard Snodgrass. The Scorpion system, August 1995. Software release. Located at
  32. 32.
    Richard Snodgrass and Karen Shannon. Supporting flexible and efficient tool integration. In Proceedings of the InternationalWorkshop on Advanced Programming Environments, number 244 in Lecture Notes in Computer Science, pages 290–313, Trondheim, Norway, June 1986.Google Scholar
  33. 33.
    Sun Microsystems. Java Language Specification, version 1.0 beta edition, October 1995. Available at
  34. 34.
    Michiaki Tatsubori, Shigeru Chiba, Marc-Oliver Killijian, and Kozo Itano. OpenJava: A class-based macro system for Java. In Walter Cazzola, Robert J. Stroud, and Francesco Tisato, editors, Reflection and Software Engineering, LNCS 1826, pages 119–135. Springer-Verlag, July 2000.CrossRefGoogle Scholar
  35. 35.
    J. Vlissides. Visitors in frameworks. C++ Report, 11(10), November 1999.Google Scholar
  36. 36.
    R. P. Wilson, R. S. French, C. S. Wilson, S. P. Amarasinghe, J. M. Anderson, S.W. K. Tjiang, S.-W. Liao, C.-W. Tseng, M. W. Hall, M. S. Lam, and J. L. Hennessy. SUIF: An infrastructure for research on parallelizing and optimizing compilers. SIGPLAN Notices, 29(12):31–37, 1994.CrossRefGoogle Scholar
  37. 37.
    Steve Zdancewic, Lantian Zheng, Nathaniel Nystrom, and Andrew C. Myers. Untrusted hosts and confidentiality: Secure program partitioning. In Proc. 18th ACM Symp. on Operating System Principles (SOSP), pages 1–14, Banff, Canada, October 2001.Google Scholar
  38. 38.
    Matthias Zenger and Martin Odersky. Extensible algebraic datatypes with defaults. In Proc. 6th ACM SIGPLAN International Conference on Functional Programming (ICFP), Firenze, Italy, September 2001.Google Scholar
  39. 39.
    Matthias Zenger and Martin Odersky. Implementing extensible compilers. In ECOOPWorkshop on Multiparadigm Programming with Object-Oriented Languages, Budapest, Hungary, June 2001.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2003

Authors and Affiliations

  • Nathaniel Nystrom
    • 1
  • Michael R. Clarkson
    • 1
  • Andrew C. Myers
    • 1
  1. 1.Cornell UniversityCornell

Personalised recommendations