I've spent the last weeks trying to get a project of mine work with Spring Native. One of my biggest problems is with serializing / deserializing objects using Jackson. I'm aware of the reason why this fails and that I can add native hints for any classes not detected in the analysis. Unfortunately this is a) a lot of work and b) error prone as I only detect the problem after having built the native image and then testing the code.
Spring Native already creates a lot of hints when the process is run during the AOT processing step. The documentation says "Static analysis of your application is performed at build-time from the main entry point.". This issue says "spring-native generates hints for classes returned by controller methods and follows the chain (via static analysis) to find referenced classes." So how exactly does that work? How can I know which classes are detected and for which I have to add hints while writing code? So far it seems to be trial and error for me. Is there a better way?
Edit: I created a ReflectionMarker
annotation which I add to all classes I expect to be serialized / deserialized (basically all with the @Data annotation from Lombok). Then in my RuntimeHintsRegistrar
I scan for those and add hints for public constructors and all declared methods. It works but still involves a manual step I can forget and feels hacky.