Affects: Spring Framework 6.0.2
- spring now support https://github.com/oracle/graal/commit/b455f23b624a1af149c7d5769443a4775bedd087 lambdaCapturingTypes?
- quarkus example: https://github.com/quarkusio/quarkus/pull/25861/files#diff-d14d5d0e8e07d50c36a60725e1848ff5a8a2e93b44888c140834e0a42552f88e
- https://github.com/quarkiverse/quarkus-mybatis/issues/184
Comment From: bclozel
I don't understand what's expected of us here. Spring Framework requires GraalVM 22.3 as a baseline, so I guess this feature is already present?
Do you have a sample Spring application that fails currently because of something missing here?
Do you want to register "lambdaCapturingTypes"
metadata yourself and would like this to be introduced in RuntimeHints
and more specifically SerializationHints
?
Without more information and a concrete use case it's hard for us to decide what to do here.
Comment From: ccwxl
yes. In Spring 6 I encountered the inability to register lambdaCapturingTypes
programmatically
Comment From: bclozel
After having a second look at the MyBatis issue I understand now. This is also something we were interested in for libraries that create lambdas as a way to make reflection faster.
Those cannot be detected during the AOT phase as they usually require running the code.
We can include this on the RuntimeHints
API but I'm not sure we should surface it on an annotation as there is no place for this for now. Marking for team attention to discuss this. Thanks for creating this issue!
Comment From: ccwxl
Thanks reply . At this stage, I use the following method to solve this problem
1. add native-image.properties
Args =--features=com.example.demo.RuntimeRegistrationFeature
- on
duringSetup
stage registerregisterLambdaCapturingClass
public class RuntimeRegistrationFeature implements Feature {
@Override
public void duringSetup(DuringSetupAccess access) {
System.out.println("duringSetup register MpController.");
RuntimeSerialization.registerLambdaCapturingClass(MpController.class);
RuntimeSerialization.register(SerializedLambda.class, SFunction.class);
}
}
Comment From: sdeleuze
@siaron I understand the aask, but I would like to assess how frequent is the need for this, could you please share a minimal repro of a failing project and more details on your concrete use case (needed for your code, a library, etc.) ?
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: grpubr
Do you want to register "lambdaCapturingTypes" metadata yourself and would like this to be introduced in RuntimeHints and more specifically SerializationHints?
YES, and also proxies
according documents in https://www.graalvm.org/latest/reference-manual/native-image/metadata/ serialization-config.json support "types" "lambdaCapturingTypes" and "proxies" but now SerializationHints just support types.
now thing may work if we write serialization-config.json manually or generate by a spring test in normal mode(not in native test). because we can approach spring beans in test. while "Feature" nativeimage are restricted, we can not get enough information to get the class we need in build time.
Comment From: grpubr
/reopen
Comment From: bclozel
@grpubr Our RuntimeHints
API is not meant to mirror the GraalVM metadata format, but rather provide actionable API for Spring AOT support. As it stands, there is no way for Spring to detect and declare lambda capturing types. If you would like to declare "lambdaCapturingTypes"
metadata, you can do so by writing your own "serialization-config.json" file in a different namespace.
Now for proxies, we do support this type of metadata through RuntimeHints#proxies()
.