What is Introspection?
Introspection is the ability for a program to observe and reason about its own state. This is useful for numerous software analysis tasks, to query not only the run-time state of a software system but also its source code.
This works by providing a reflective API to query the run-time system. In Smalltalk, this is done by reifying metaobjects of the runtime so they can be queried.
Some examples of metaobjects are:
— Smalltalk
, a Facade for interacting with the running image.
— The core classes of the Smalltalk system, such as Behavior
, Class
and Metaclass
— Any class
We will have a closer look at concrete examples in three parts:
Querying objects — shows examples of querying an object's reference, state and class.
Querying classes and methods — shows how to reflectively query classes and methods using numerous APIs.
Querying the runtime — shows how to query the run-time stack of execution contexts