Closed artembilan closed 1 year ago
Hi @artembilan,
can I merge this as-is to add support for GraalVM? I really have no time to dig deeper into this but at least I'm sure that this change does not break anything 🙃
Regards, Patrick
You are right: it does not. As you see there is no code change , but this will help consumers of this project to be able to build GraalVM native images smoothly.
Thanks for your contribution. I've merged it right now and all your mentioned improvements are planned for the future :)
Good. Let me know when those changes are in, so I'll try it against native image and possibly contribute back according to a new state of matters.
Fixes https://github.com/rometools/rome/issues/599
There is a lot of reflection in the project which probably has to be reworked this or other way eventually. But for now it is enough to have a proper reflection info exposed for GraalVM when it builds a native image for our application.
Used a
native-image-agent
to take a required native image config from the running sample application. More info in GraalVM docs: https://www.graalvm.org/22.0/reference-manual/native-image/Agent/. Works only if GraalVM is used to run the application, of course.In general it is probably better to rework all the content of the
rome.properties
into a Java ServiceLoader API.There is also too much
clone()
operations with reflection in the project: perhaps better to look into something like deep copy approach.So, the fix is like this:
META-INF/native-image/romtools/resource-config.json
to make all the properties from the project available for native imageMETA-INF/native-image/romtools/reflect-config.json
for classes in the project used for reflection Mostly content of these files is generated by the mentioned above GraalVM agentLOG
property from theCopyFromHelper
since it is used only to log an error where we re-throw it immediately anyway. This was an attempt to see ifinitialize-at-build-time
for some classes helps us somehow since there is a lot ofstatic
initialization, but turns out we still do thatclone()
with reflection, so pointless.