-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support MethodHandle invocation with primitive varargs array in SpEL
Prior to this commit, the Spring Expression Language (SpEL) could not invoke a varargs MethodHandle function with a primitive array containing the variable arguments, although that is supported for a varargs Method function. Attempting to do so resulted in the first element of the primitive array being supplied as a single argument to the MethodHandle, effectively ignoring any variable arguments after the first one. This commit addresses this by updating the convertAllMethodHandleArguments(...) method in ReflectionHelper as follows when the user supplies the varargs already packaged in a primitive array. - Regarding conversion, use the wrapper type for a primitive varargs array, since we eventually need an Object array in order to invoke the MethodHandle in FunctionReference#executeFunctionViaMethodHandle(). - When deciding whether to convert a single element passed as varargs, we now check if the argument is an array that is assignable to the varargs array type. - When converting an array supplied as the varargs, we now convert that array to the varargs array type instead of the varargs component type. Note, however, that a SpEL expression cannot provide a primitive array for an Object[] varargs target. This is due to the fact that the ArrayToArrayConverter used by Spring's ConversionService does not support conversion from a primitive array to Object[] -- for example, from int[] to Object[]. See gh-33191 Closes gh-33198
- Loading branch information
Showing
5 changed files
with
124 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters