Java / Micronaut Interview questions
What is the difference between Micronaut's bean introspection and Java reflection?
BeanIntrospection is Micronaut's compile-time alternative to reflective bean inspection: it lets you read and write properties, and get annotation metadata, without ever calling into java.lang.reflect at runtime.
@Introspected public class Order { private String id; // getters/setters } BeanIntrospection<Order> intro = BeanIntrospection.getIntrospection(Order.class); BeanProperty<Order, String> idProp = intro.getRequiredProperty("id", String.class);
| Java Reflection | BeanIntrospection |
| Metadata computed at runtime via Class introspection. | Metadata generated at compile time by the annotation processor. |
| Slower per-access; requires setAccessible for private members. | Direct generated method calls; no accessibility workarounds needed. |
| Often blocked or restricted under GraalVM native image without config. | Fully native-image compatible with zero extra configuration. |
This is why libraries like Micronaut Serialization use @Introspected classes for JSON binding instead of a purely reflection-based approach, keeping serialization both faster and native-image-safe.
More Related questions...