Previous paper

Next paper

Reflecting on an Existing Programming Language

Andreas Leitner, Dept. of Computer Science, ETH Zurich, Switzerland
Patrick Eugster, Dept. of Computer Science, Purdue University, USA
Manuel Oriol, Dept. of Computer Science, ETH Zurich, Switzerland
Ilinca Ciupa, Dept. of Computer Science, ETH Zurich, Switzerland


PDF Icon
PDF Version


Reflection has proven to be a valuable asset for programming languages, especially object-oriented ones, by promoting adaptability and extensibility of programs. With more and more applications exceeding the boundary of a single address space, reflection comes in very handy for instance for performing conformance tests dynamically.

The precise incentives and thus mechanisms for reflection vary strongly between its incarnations, depending on the semantics of the considered programming language, the architecture of its runtime environment, safety and security concerns, etc. Another strongly influential factor is legacy, i.e., the point in time at which the corresponding reflection mechanisms are added to the language. This parameter tends to dictate the feasible breadth of the features offered by an implementation of reflection.

This paper describes a pragmatic approach to reflection, consisting in adding introspection to an existing object-oriented programming language a posteriori, i.e., without extending the programming language, compiler, or runtime environment in any specific manner. The approach consists in a pre-compiler generating specific code for types which are to be made introspectable, and an API through which this code is accessed.

We present two variants of our approach, namely a homogeneous approach (for type systems with a universal root type) and a heterogeneous approach (without universal root type), and the corresponding generators. We discuss limitations such as infinite recursion, and compare the code generated with these two approaches by Erl-G, a reflection library generator for the Eiffel programming language, thereby quantifying the benefits of a universal root type. Erl-G is being used by several tools for development in Eiffel.

Note: Due to the typographical sophistication of this article, no HTML version is available. Please use the PDF version.

About the authors


Andreas Leitner is a PhD student and research assistant at the Chair of Software Engineering at the ETH Zurich, Switzerland. His research focus is on contract based testing and software engineering in general. He received his masters degree from Graz University of Technology, Austria, in January 2005. He can be reached at

  Patrick Eugster is an assistant professor at Purdue University. He is interested in distributed programming, touching upon programming abstractions and languages, middleware, and distributed systems. Patrick holds both an M.S. and Ph.D. degree from the Swiss Federal Institute of Technology in Lausanne, Switzerland (EPFL), and is a recipient of the NSF CAREER award. He can be reached at

  Manuel Oriol is a postdoctoral researcher at the Chair of Software Engineering at ETH Zurich. His main areas of interest are coordination, middleware, components infrastructures, dynamic software updating and software testing. He can be reached at
  Ilinca Ciupa is a PhD student at the Chair of Software Engineering working on developing and evaluating techniques for automated software testing based on the principles of Design by Contract. She became a PhD student at the ETH in July 2005, after being an academic guest in the group since October 2004 and graduating as Dipl. Eng. from the Technical University of Cluj-Napoca, Romania, in September 2004. She can be reached at

Cite this document as follows: Andreas Leitner, Patrick Eugster, Manuel Oriol, Ilinca Ciupa: "Reflecting on an Existing Programming Language", in Journal of Object Technology, vol. 6, no. 9, Special Issue: TOOLS EUROPE 2007, October 2007, pages 319-339,

Previous paper

Next paper