Closed ccwxl closed 1 year ago
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.
yes. In Spring 6 I encountered the inability to register lambdaCapturingTypes
programmatically
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!
Thanks reply . At this stage, I use the following method to solve this problem
native-image.properties
Args =--features=com.example.demo.RuntimeRegistrationFeature
duringSetup
stage register registerLambdaCapturingClass
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);
}
}
@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.) ?
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.
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.
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.
/reopen
@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()
.
Affects: Spring Framework 6.0.2