Reflection Using Hierarchical Iterators
Reflection deals with obtaining information about executing programs. This includes static information such as the structure of types, fields and methods as well as runtime information such as the contents of the activation stack and the heap.
We show a simple technique for accessing this metainformation in a uniform way. The general idea is to organize the metainformation as a nested sequence of elements that can be traversed using iterators (so-called riders). Instead of keeping metaobjects in main memory we store them in a reference file and let the iterators parse the file. In this way, reflection imposes only a negligible memory overhead. Users don't have to pay for this feature if they don't use it.
In contrast to some other reflection models iterators not only allow us to explore the static program structure but also the runtime data. For example, an iterator can traverse the activation frames on the stack, zoom into a particular frame, traverse the variables in this frame, zoom into a structured variable and so on until the desired information is found.
Our reflection model has been implemented for the Oberon system and has been used for a number of system programming tasks including a general IO module, an exception handling mechanism and a database binding.
This is a talk given at the Dagstuhl Seminar 451 on Effective Implementation of Object-Oriented Programming Languages, Nov.6-10, 2000.
You can download the slides of the talk in PDF.