New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build time initialization of org.springframework.util.unit.DataSize #4489
Comments
Please tag this issue with the |
Hi, Thank you for reporting this we will take a look into it and get back to you |
I tried to reproduce, but I get a Java build error on the last step (building
And indeed when looking at https://github.com/mhalbritter/spring-framework/tree/mh/data-size/spring-core/src/main/java/org/springframework/aot/hint there is no file Is there something out of sync with the branches for spring-framework and spring-boot? |
Yes, sorry about that. Please remove that tomcat class as well as the import that it references on the main class as neither are necessary to reproduce. Alternatively you could checkout the previous commit. Thanks for looking at this! |
I can reproduce the problem. This is a corner case triggered by the combination of annotations, enums, and classes that cannot trivially be initialized at image build time:
We are trying to fix this corner case (fyi @loicottet, @vjovanov) but it requires re-working a lot of code that currently accesses annotations eagerly. But I think you can work around the problem in Spring: you only need to get the field |
Thanks for the analysis and tips, @christianwimmer. We will start initializing the |
@nicolasesprit I am not sure why you are linking this Spring Native (based on Spring Framework 5.3) troubleshooting documentation entry. We modified Spring Framework 6 to workaround this issue as pointed our by @sbrannen. Could you share more details? |
The underlying issue of initializing annotations at build-time has been patched on master by 9da460f |
Thanks! |
Hey,
I'm struggling to understand build time initialization. I don't get why the build time initialization of
org.springframework.util.unit.DataSize
is necessary in our spring-boot native image.The native image building fails if we don't include
--initialize-at-build-time=org.springframework.util.unit.DataSize
.I wasn't able to build a minimal reproducer for this. Here's the full reproducer:
When running this, i get the error
When adding the
--trace-object-initialization=...
from the error message, I get:Adding
--initialize-at-build-time=org.springframework.util.unit.DataSize
works, but why is this necessary?The only thing which we initialize at build time (via native-image.properties file in
spring-core.jar
) isorg.springframework.core.NativeDetector
.I used the latest available 22.1-dev build (https://github.com/graalvm/graalvm-ce-dev-builds/releases/tag/22.1.0-dev-20220411_0809)
OS is Linux aarch64.
The text was updated successfully, but these errors were encountered: