API / Apache Velocity Interview questions
What is the Uberspector in Velocity and what problem does it solve?
The Uberspector is Velocity's pluggable introspection layer, the component responsible for turning a reference like $user.name or $order.getTotal() into an actual reflective method or field lookup against whatever Java object is bound to that name in the context.
Without it, VTL would need hardcoded knowledge of every class it might ever encounter; instead, the default UberspectImpl uses standard Java reflection and JavaBean conventions (trying getX() for a property named x, falling back to a public field) so any plain Java object can be dropped into a context and used from a template without special adapter code.
Because that flexibility is also a security surface, since unrestricted reflection could reach dangerous classes, Velocity ships a SecureUberspector variant that blocks introspection on a configurable denylist of "dangerous" classes and methods, and applications handling untrusted templates are expected to use it (or an equivalent) instead of the permissive default.
More Related questions...