In Java, I am able to combine multiple method handle with each its parameters, like this:
foo( a, bar( 2, b ) )
..by using MethodHandles.collectArguments().
The method handle I get can be called like this :
myHandle.invokeExact( 5, 6 ); // invokes foo(5, bar(2, 6))
But now, I would like to get a Method Handle that dispatches its parameters into the call tree like this:
MethodHandle myHandle = ...; // foo( *x*, bar( 2, *x* ) )
myHandle.invokeExact( 3 ); // replaces x by 3 in both locations
// this call represents 'foo(3, bar(2, 3));'
I cannot wrap my head around about how to do that. Can you help me?