The core framework invokes @RequestMapping
-annotated methods (@GetMapping
, etc) using reflection. To run in a native image, we need hints for those. We may also want to infer that return types are going to be serialized, or that input times are going to be mapped from the request.
All this can go away if we generate an optimized code for the router but let's go the hints route for now.
Comment From: snicoll
For the annotations themselves and loading org/springframework/http/mime.types
it would be nice if those were contributed only if the application is going to use it. Adding a RuntimeHintsRegistrar
in aot.factories
would not achieve that goal but it's not clear cut where to put @ImportRuntimeHints
. As it should be consistent, we can't really rely on Spring Boot for that.
For the annotations, I was tempted to add an import on org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
but it's not obvious that's going to be a bean so the annotation there feels a little bit odd.
Comment From: snicoll
Considering that MergedAnnotations
is required to automatically handle the creation of the proxy. I wonder if dealing with everything that is method specific can be a good thing. This would be more code but more tailored to what is actually happening in the application.
Comment From: sdeleuze
I managed to make webmvc-tomcat
sample working with https://github.com/sdeleuze/spring-framework/tree/gh-28518. I will refine it based on @snicoll feedback.
Comment From: sdeleuze
This issue will be focused on reflection hints for controllers and reflection-based serialization of parameters annotated
with @RequestBody
and return values annotated with @ResponseBody
. I will create subsequent issues for other use-cases (HttpEntity
, @ControllerAdvice
, etc.)