Skip to content

Record beans do not compile to native images #30383

Closed
@sdeleuze

Description

@sdeleuze

After this change related to #29246 in Spring Framework 6.0.8, "queryAllDeclaredMethods": true is added on all registered beans (for good purpose).

I think this change has uncovered the fact that Boot is not adding invocation hints for record components on @ConfigurationProperties (like ReflectionForBindingRegistrar does on Framework side). Before Spring Framework 6.0.7, records components were, I guess, invisible so no error. With Spring Framework 6.0.8+, "queryAllDeclaredMethods": true make those records components visible.

That means with Boot 3.0.6, with:

@ConfigurationProperties("sample")
record SampleConfigurationProperties(String message) { }

I get the following error:

Fatal error: com.oracle.svm.core.util.VMError$HostedError: com.oracle.svm.core.util.VMError$HostedError: New Method or Constructor found as reachable after static analysis: public java.lang.String com.example.SampleConfigurationProperties.message()

Can be reproduced with https://github.com/sdeleuze/demo-profile-aot when updating to Boot 3.0.6.

To avoid such error and properly support record component binding in @ConfigurationProperties, I think invocation hints should be added to record components for such class.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)theme: aotAn issue related to Ahead-of-time processingtype: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions