GH-8613: Add JsonPropertyAccessor type for native (#8614)

Fixes https://github.com/spring-projects/spring-integration/issues/8613

If `JsonPropertyAccessor` is registered for SpEL, it would be great
to have it working in native images as well.

Since SpEL is fully based on reflection, expose
`JsonPropertyAccessor$ComparableJsonNode` and `JsonPropertyAccessor$ArrayNodeAsList`
reflection hints for their method invocations from SpEL

**Cherry-pick to `6.0.x`**
This commit is contained in:
Artem Bilan
2023-05-08 10:31:23 -04:00
committed by GitHub
parent b999ac109c
commit ffe50d2d30

View File

@@ -34,6 +34,7 @@ import org.springframework.aot.hint.ReflectionHints;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.SerializationHints;
import org.springframework.aot.hint.TypeReference;
import org.springframework.beans.factory.config.BeanExpressionContext;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.aggregator.MessageGroupProcessor;
@@ -101,6 +102,14 @@ class CoreRuntimeHints implements RuntimeHintsRegistrar {
reflectionHints.registerType(JsonPathUtils.class, MemberCategory.INVOKE_PUBLIC_METHODS);
}
reflectionHints.registerType(
TypeReference.of("org.springframework.integration.json.JsonPropertyAccessor$ComparableJsonNode"),
MemberCategory.INVOKE_PUBLIC_METHODS);
reflectionHints.registerType(
TypeReference.of("org.springframework.integration.json.JsonPropertyAccessor$ArrayNodeAsList"),
MemberCategory.INVOKE_PUBLIC_METHODS);
// For #xpath() SpEL function
reflectionHints.registerTypeIfPresent(classLoader, "org.springframework.integration.xml.xpath.XPathUtils",
MemberCategory.INVOKE_PUBLIC_METHODS);