This commit allows to set the XmlBeanDefinitionReader
field from BeanDefinitionLoader
to null
in a way that allows the GraalVM native compiler to remove it from the native image when the spring.xml.ignore
flag introduced by spring-projects/spring-framework#25151 is set to true
. The Groovy reader which relies on the XML one is disabled as well when the spring.xml.ignore flag
is set to true
.
The purpose of this change is to allow smaller footprint on native images without requiring to use GraalVM native substitutions which are unmaintainable by nature and also to increase the consistency between JVM and native images.
In order to effective, this optimization requires BeanDefinitionLoader
class to be initialized at build time.
Comment From: sdeleuze
I have updated this PR to focus only on disabling the XML reader as suggested by @wilkinsona. I was initially confused by the fact that private int load(GroovyBeanDefinitionSource source)
used both XML and Groovy readers, but since its return value seems to be not used I was able to remove this cross dependency. I have validated via spring-graalvm-native
that the code removal is still effective. Please let me know if I missed something.