The Spring Expression Language (SpEL) currently cannot invoke a varargs MethodHandle function with zero variable arguments.
Attempting to do so results in a SpelEvaluationException with an INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION message.
For example, given a MethodHandle registered as a function named format that accepts (String, Object...), the SpEL expression #format('x', 42) is supported, but the expression #format('x') fails even though the variable arguments are not required.
The following assertion in our test suite should therefore not actually fail due to a SpelEvaluationException with an INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION message but rather due to an exception thrown from java.lang.String.formatted(Object...), which that #message() function invokes on the first argument.
|
evaluateAndCheckError("#message('%s')", INCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTION, 0, "message", 1, 2); |
The Spring Expression Language (SpEL) currently cannot invoke a varargs
MethodHandlefunction with zero variable arguments.Attempting to do so results in a
SpelEvaluationExceptionwith anINCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTIONmessage.For example, given a
MethodHandleregistered as a function namedformatthat accepts(String, Object...), the SpEL expression#format('x', 42)is supported, but the expression#format('x')fails even though the variable arguments are not required.The following assertion in our test suite should therefore not actually fail due to a
SpelEvaluationExceptionwith anINCORRECT_NUMBER_OF_ARGUMENTS_TO_FUNCTIONmessage but rather due to an exception thrown fromjava.lang.String.formatted(Object...), which that#message()function invokes on the first argument.spring-framework/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java
Line 59 in c6b20c0