mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-08 08:09:09 +00:00
Register native configuration file when only lambda hints are present
Prior to this commit, FileNativeConfigurationWriter did not write reachability-metadata.json when a RuntimeHints instance contained only lambda hints, because NativeConfigurationWriter.hasAnyHint() omitted ReflectionHints.lambdaHints() from its checks. As a result, lambda metadata emitted by RuntimeHintsWriter was silently dropped. This commit addresses that by including lambda hints in hasAnyHint() so the configuration file is written whenever lambda hints are present. Closes gh-36989 Signed-off-by: junhyeong9812 <pickjog@gmail.com>
This commit is contained in:
+1
@@ -46,6 +46,7 @@ public abstract class NativeConfigurationWriter {
|
||||
private boolean hasAnyHint(RuntimeHints hints) {
|
||||
return (hints.proxies().jdkProxyHints().findAny().isPresent() ||
|
||||
hints.reflection().typeHints().findAny().isPresent() ||
|
||||
hints.reflection().lambdaHints().findAny().isPresent() ||
|
||||
hints.resources().resourcePatternHints().findAny().isPresent() ||
|
||||
hints.resources().resourceBundleHints().findAny().isPresent() ||
|
||||
hints.jni().typeHints().findAny().isPresent() ||
|
||||
|
||||
+29
@@ -23,6 +23,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
@@ -137,6 +138,34 @@ class FileNativeConfigurationWriterTests {
|
||||
""");
|
||||
}
|
||||
|
||||
@Test // gh-36989
|
||||
void lambdaConfig() throws Exception {
|
||||
FileNativeConfigurationWriter generator = new FileNativeConfigurationWriter(tempDir);
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
hints.reflection().registerLambda(Integer.class, builder -> builder
|
||||
.withDeclaringMethod("getCell", Integer.class, Integer.class)
|
||||
.withInterfaces(Supplier.class));
|
||||
generator.write(hints);
|
||||
assertEquals("""
|
||||
{
|
||||
"reflection": [
|
||||
{
|
||||
"type": {
|
||||
"lambda": {
|
||||
"declaringClass": "java.lang.Integer",
|
||||
"declaringMethod": {
|
||||
"name": "getCell",
|
||||
"parameterTypes": [ "java.lang.Integer", "java.lang.Integer" ]
|
||||
},
|
||||
"interfaces": [ "java.util.function.Supplier" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
""");
|
||||
}
|
||||
|
||||
@Test
|
||||
void jniConfig() throws Exception {
|
||||
// same format as reflection so just test basic file generation
|
||||
|
||||
Reference in New Issue
Block a user