Mirror (programming)

In computer programming, a mirror is a reflection mechanism that is completely decoupled from the object whose structure is being introspected. This is as opposed to traditional reflection, for example in Java, where one introspects an object using methods from the object itself (e.g. java.lang.Object::getClass() to get a java.lang.Class<?>).

Mirrors adhere to the qualities of encapsulation, stratification and ontological correspondence.

Benefits

Decoupling the reflection mechanism from the objects themselves allows for a few benefits:

Languages that use mirrors

See also

References

  1. ↑ Gilad Bracha and David Ungar, "Meta-level Facilities of Object-Oriented Programming languages"
  2. ↑ cppreference.com. "std::meta::info". cppreference.com. Retrieved 19 May 2026.
  3. ↑ "Frequently Asked Questions".
  4. ↑ "Rubinius/Mirror.rb at master · rubinius/Rubinius".
  5. ↑ The Rust Team (8 September 2026). "Struct Type". doc.rust-lang.org. The Rust Team.
  6. ↑ "Environment, Universes, and Mirrors".