-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Expected Behavior
JsonPropertyAccessor should be usable out of the box in GraalVM native images by providing proper reflection configuration.
Current Behavior
Evaluating an SpEL expression that invokes a List method like List::contains on a Jackson ArrayNode fails with the following exception message:
org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method contains(java.lang.String) cannot be found on type org.springframework.integration.json.JsonPropertyAccessor$ArrayNodeAsList
Context
We have a command-line application that invokes various REST endpoints and allows users to specify SpEL expressions to filter the results. We create our SpEL EvaluationContext using the following method:
private static final EvaluationContext createSpelEvaluationContext() {
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
conversionService.addConverter(new JsonNodeWrapperToJsonNodeConverter());
conversionService.addConverter(new ObjectToJsonNodeConverter());
DateTimeFormatterRegistrar dateTimeRegistrar = new DateTimeFormatterRegistrar();
dateTimeRegistrar.setDateFormatter(DateTimeFormatter.ISO_DATE);
dateTimeRegistrar.setDateTimeFormatter(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
dateTimeRegistrar.registerFormatters(conversionService);
SimpleEvaluationContext context = SimpleEvaluationContext
.forPropertyAccessors(new JsonPropertyAccessor())
.withConversionService(conversionService)
.withInstanceMethods()
.build();
return context;
}When a user specifies a filtering expression like someJsonArrayProperty.contains('someValue'), this works fine in the regular Java version of our CLI application, but fails in the native images.