IT lexicon › Programming › Reflection

Reflection

Programming På svenska → Updated: 2026-05-23

A program's ability to inspect and manipulate its own structure at runtime — list classes, get fields, invoke methods by string name.

The heart of the Java/.NET ecosystems (Spring, Jackson, ORMs, mocking libraries). Python's equivalent is getattr/setattr + inspect. Statically compiled languages have less or none: Rust has std::any::Any and almost nothing else; Go has reflect, which is clumsy and slow.

Trade-off: powerful, but destroys compile-time safety, makes tree-shaking hard, and trips up AOT compilers (GraalVM, iOS). Modern trend: replace reflection with code generation (Rust serde, Java records, Go generics) where possible.

← Back to the lexicon