-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Cascaded and container element constraints on a @ConfigurationProperties class do not work correctly in a native image #37101
Comments
I can reproduce, but:
demo:
context:
exclude:
-
httpStatus:
- "2xx"
|
See the related stacktrace with the refined |
Thank you for your review. But that code works fine with jvm not graalvm. Result when "7xx" is value in jvm.
It doesn't work only in graalvm native image. Why is this problem occurring? |
The validation doesn't work for me on the JVM either:
@KimSeongIl, so that we can be certain that we're looking at exactly the same thing, please provide a complete yet minimal sample that reproduces the behaviour you have described. Guessing dependencies and copy-pasting code from issue comments leaves to much room for unwanted differences. |
https://github.com/KimSeongIl/demo Created a demo project. The problem is reproduced in this project. Could you please check again? |
https://github.com/KimSeongIl/demo in the demo project tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xemit-jvm-type-annotations")
jvmTarget = "11"
} -Xemit-jvm-type-annotations option works fine in jvm environment. Do I need to use other options in a graalvm environment? |
Thanks, @KimSeongIl. I've been able to explore the problem now. The problem occurs because Spring Boot's configuration property binding cannot identify the constructor to use to create an instance of Lines 202 to 208 in f0e1fdf
On the JVM, |
Digging a little more before transferring the issue shows that the primary constructor is null due to an
This is looking more like a GraalVM bug to me as it appears to have failed to include |
That's not the problem. Changing the main function to reference
This outputs Perhaps We'll transfer this to Framework to get some of @sdeleuze's Kotlin expertise. |
After a deeper look, it looks like a GraalVM bug to me. I am not sure GraalVM is supposed to add the related annotation reflection config transitively based on
We will see the feedback from GraalVM team. |
@snicoll @bclozel @mhalbritter @wilkinsona It looks like we have been going full circle on this one. GraalVM confirmed this need to be fixed on Spring side, and after a another look I agree. I had a deeper look on Spring Boot side while debugging, and I think I now understand why As a consequence, I think this issue should be bring back to Spring Boot side where advanced validation handling like Notice that a logic similar to If some refinements are needed on Spring Framework side like extracting |
This validation of From Spring Boot's perspective, this should work in a native image if Once a fix has been made in Framework, we should be able to fix this by documenting in this section that |
The Framework change has been made in 6.2 only due to its complexity. As such, there's nothing more that we can do here. Boot 3.4 already documents the need to use |
spring boot version: 3.1.0
graalvm plugin version: id("org.graalvm.buildtools.native") version "0.9.20"
graalvm version: 22.3.r17
DemoContext.kt
application.yml
nativeRun result
It worked fine before, but when I run it on the native image I get an error.
However, if I remove the Pattern annotation, it works fine.
Why is this problem occurring?
What should I do to resolve this?
The text was updated successfully, but these errors were encountered: