Skip to content

Conversation

sdeleuze
Copy link
Contributor

@sdeleuze sdeleuze commented Mar 3, 2022

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.

@sdeleuze sdeleuze added in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing labels Mar 3, 2022
@sdeleuze sdeleuze requested a review from jhoeller March 3, 2022 14:37
@snicoll snicoll added the type: enhancement A general enhancement label Mar 3, 2022
@sdeleuze
Copy link
Contributor Author

sdeleuze commented Mar 8, 2022

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

@sdeleuze
Copy link
Contributor Author

sdeleuze commented Mar 8, 2022

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

@bclozel
Copy link
Member

bclozel commented Mar 9, 2022

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?

@sdeleuze sdeleuze force-pushed the gh-27991 branch 2 times, most recently from 421e0df to 79e0f13 Compare March 10, 2022 17:48
@sdeleuze
Copy link
Contributor Author

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

@sdeleuze
Copy link
Contributor Author

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

This commit implements 4 package private Json serializers
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 via the
FileNativeConfigurationGenerator implementation.

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

Closes spring-projectsgh-27991
@sdeleuze sdeleuze force-pushed the gh-27991 branch 2 times, most recently from 834c48d to 2e25f34 Compare March 16, 2022 15:10
@sdeleuze
Copy link
Contributor Author

Merged via 77e0100.

@sdeleuze sdeleuze closed this Mar 16, 2022
@snicoll snicoll added this to the 6.0.0-M3 milestone Mar 16, 2022
@snicoll snicoll changed the title Implement GraalVM native JSON configuration generation Add GraalVM native JSON configuration generation Mar 16, 2022
@sdeleuze sdeleuze deleted the gh-27991 branch December 10, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants