After this change related to https://github.com/spring-projects/spring-framework/issues/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.

Comment From: wilkinsona

It looks like the configuration properties smoke test started failing with a similar error on 19 April:

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 com.example.configprops.records.NestedNotInner com.example.configprops.records.AppPropertiesRecord.nestedNotInner() 
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:72) 
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:696)  
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535)    
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403) 
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580)  
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)   
Caused by: com.oracle.svm.core.util.VMError$HostedError: New Method or Constructor found as reachable after static analysis: public com.example.configprops.records.NestedNotInner com.example.configprops.records.AppPropertiesRecord.nestedNotInner() 
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:68) 
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.reflect.ReflectionFeature.getOrCreateAccessor(ReflectionFeature.java:121)  
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.target.ExecutableAccessorComputer.transform(ExecutableAccessorComputer.java:43)  
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.ComputedValueField.computeValue(ComputedValueField.java:343)    
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.substitute.ComputedValueField.readValue(ComputedValueField.java:313)   
    at org.graalvm.nativeimage.builder/com.oracle.svm.core.meta.ReadableJavaField.readFieldValue(ReadableJavaField.java:38) 
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readValue(AnalysisConstantReflectionProvider.java:97) 
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.meta.HostedField.readValue(HostedField.java:161)   
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.addObjectToImageHeap(NativeImageHeap.java:439)   
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.addObject(NativeImageHeap.java:295)  
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.processAddObjectWorklist(NativeImageHeap.java:598)   
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.image.NativeImageHeap.addTrailingObjects(NativeImageHeap.java:198) 
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:678)  
    ... 4 more

That was when the smoke tests were updated to test Boot 3.0.6 snapshots. This fits with the Framework changes being related as moving to Boot 3.0.6 snapshots meant we also upgraded to Framework 6.0.8.

Comment From: snicoll

This commit workarounds this GraalVM bug, and should be removed once the GraalVM fix has reached a wide enough audience.

Please create a task to remove the code or we will probably forget about it. Thanks!

Comment From: AdrienBennadji

Hi, not sure if I should open a new issue of reopen this one but migrating my application to spring-boot 3.2.0 seems to break records again.

Caused by: com.oracle.svm.core.util.VMError$HostedError: New Method or Constructor found as reachable after static analysis: public <redacted>.AppProperties$Secured <redacted>.AppProperties.secured()

Here AppProperties and Secured are both records, and I use @NestedConfigurationProperty. Changing from records to classes make the compilation work.

Comment From: sbrannen

@AdrienBennadji, since this issue was closed 8 months ago, please open a new issue.

And in that issue, please include a small example that reproduces the problem -- preferably a simple application or test class that we can run ourselves (either attached to the issue as a ZIP file or as a public Git repository).

Thanks

Comment From: AdrienBennadji

@sbrannen Thank you for your response. I upgraded the version of the Graalvm image i use to build my applications and it fixed the issue.