Reflection in Java
Reflection inspects and manipulates classes at runtime. It powers most frameworks and should be rare in application code.
Reflection, proxies, modules, sealed types, immutability and modern features.
6 notes
Reflection inspects and manipulates classes at runtime. It powers most frameworks and should be rare in application code.
A dynamic proxy implements an interface at runtime and routes every call through one handler, which is how cross cutting behaviour is added.
Modules add a boundary above packages: a module declares what it needs and what it exposes, and everything else stays private.
A sealed type names exactly which types may extend it, which lets the compiler check that a pattern switch covers every case.
An immutable object cannot change after construction, which removes whole categories of bug at the cost of a little copying.
What changed in each release since Java 8, which old habits it replaces, and what to reach for in new code today.