Here is a PR intended to be a proposal to implement #27991.

The related commit implements 4 package private Jackson JsonSerializer for JavaSerializationHints, ProxyHints, ReflectionHints and ResourceHints to serialize GraalVM native JSON configuration as documented in https://www.graalvm.org/22.0/reference-manual/native-image/BuildConfiguration/.

It exposes the related functionality via NativeConfigurationGenerator which allows to generate the relevant files on the filesystem.

The generated *-config.json files has been validated working with GraalVM 22.0.

Looking forward to your feedback @jhoeller.

Comment From: sdeleuze

I think I am going to update that PR to use RuntimeHints in NativeConfigurationGenerator.

Comment From: sdeleuze

I have updated the PR to expose a single public void generate(RuntimeHints hints, Path targetDirectory) method in NativeConfigurationGenerator.

Comment From: bclozel

I've just discussed this with @sdeleuze because I remembered a specific point about the AOT processing in Spring Native: this processing phase is triggered by the build plugins as they fork a JVM process using the application runtime classpath. This last point is necessary since all the classloader detections need to happen in a consistent fashion with the actual runtime behavior of the application.

Using Jackson as a required dependency means that build plugins would have to artificially add Jackson as a dependency to the runtime classpath, thus invalidating Jackson auto-detection during the AOT processing. This is why in Spring Native we chose to use/shade the vaadin "android-json" dependency to manipulate JSON. We had more specific needs there, such as reading/merging/writing JSON documents. In this case, since we're only writing a document out, maybe we should use a StringBuffer approach and avoid this problem completely?

Comment From: sdeleuze

@bclozel @snicoll Could you please review the updated PR and let me know your advice?

Comment From: sdeleuze

The application used to validate it works as expected is https://github.com/sdeleuze/generate-native-config.

Comment From: sdeleuze

Merged via 77e0100f42253ab26947cf2258ee9653e2ac811d.