From ffe50d2d303b1348bd2b718358f2e7ddb30a403c Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 8 May 2023 10:31:23 -0400 Subject: [PATCH] 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`** --- .../integration/aot/CoreRuntimeHints.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aot/CoreRuntimeHints.java b/spring-integration-core/src/main/java/org/springframework/integration/aot/CoreRuntimeHints.java index f528bab797..45c6937759 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aot/CoreRuntimeHints.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aot/CoreRuntimeHints.java @@ -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);