This commit adds support for MethodHandles in SpEL, using the same syntax as user-defined functions (which also covers reflective Methods).

The most benefit is expected with handles that capture a static method with no arguments, or with fully bound handles (where all the arguments have been bound, including a target instance as first bound argument if necessary). Partially bound MethodHandle should also be supported.

A best effort approach is taken to detect varargs as there is no API support to determine if an argument is a vararg or an explicit array, unlike with Method. Argument conversions are also applied. Finally, array repacking is not always necessary with varargs so it is only performed when the vararg is the sole argument to the invoked method.

Closes gh-27099 Closes gh-30045

Comment From: simonbasle

@ericbottard if you're still interested, feel free to test that out and validate this covers your original use case 😉

Comment From: ericbottard

A quick glance at the docs and test tells me this would have been useful. We went with another route (and that leaked in the exposed API sadly), but glad to see this got supported eventually. Thanks!

Comment From: simonbasle

Now rebased on top of latest reference doc changes (Antora) and squashed into a single commit.

Comment From: fanthos

Is it possible to backport this feature to 5.x? Java 17 is not ready in many environments.

Comment From: simonbasle

Is it possible to backport this feature to 5.x? Java 17 is not ready in many environments.

@fanthos this is very unlikely. We don't backport purely new features to the 5.3.x line, and now that the work has started on 6.1.x, we tend to avoid doing so in 6.0.x as well.

edit: got confused, MethodHandle is from Java 8. but the above point still stands