Argument handling

Three recent updates were made to improve MethodHandle argument handling. These changes are highlighted as follows:

  • Argument folding using foldArguments(MethodHandle target, MethodHandle combinator) did not previously have a position argument:
    • Argument collection using the MethodHandle.asCollector(Class<?> arrayType, int arrayLength) method did not previously support collecting the arguments into an array except for the trailing element. This has been changed, and there is now an additional asCollector method to support that functionality.
  • Argument spreading using the MethodHandle.asSpreader(Class<?> arrayType, int arrayLength) method spreads the contents of the trailing array to a number of arguments, in a reverse method of argument collection. Argument spreading has been modified to support the expansion of an array anywhere in the method signature.
The new method definitions for the updated asCollector and asSpreader methods are provided in the next section.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset