After experimenting with MethodHandles.collectArguments (given a
hand-written collector function) versus my own logic (using folds and
permutes to call my collector), I can confirm that both are roughly
equivalent and better than MethodHandle.asCollector.
The benchmark linked below calls a
JRuby branch with changes to use our own collector methods:
https://github.com/jruby/jruby/pull/6630
InvokeBinder 1.2 added collect(index, type, collector) that calls
MethodHandles.collectArguments:
https://github.com/headius/invokebinder/commit/9650de07715c6e15a8ca4029c40ea5ede9d5c4c9
A build
Well it only took me five years to circle back to this but I can
confirm it is just as bad now as it ever was. And it is definitely due
to collecting a single type.
I will provide whatever folks need to investigate but it is pretty
straightforward. When asking for asCollector of a non-Object[]