JDK-8186469 : MethodHandle.invokeWithArguments jumbo-arity
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 10
  • Submitted: 2017-08-18
  • Updated: 2018-01-08
  • Resolved: 2017-08-31
Related Reports
CSR :  
Description
Summary
-------

Update the specification of `MethodHandle.invokeWithArguments` to support an arity of more than 251 (referred to as jumbo-arity) if the method handle has variable arity with the trailing parameter, whereby additional arguments will be accumulated into an array of the appropriate type with appropriate asType conforming conversions.

Update the specification of bootstrap method invocation to invoke a bootstrap method handle with `MethodHandle.invokeWithArguments` instead of `MethodHandle.invoke` (the latter is equivalent to the former if the number of arguments is below the currently supported maximum limit).


Problem
-------

Currently `MethodHandle.invokeWithArguments` is limited to 251 arguments (255 - 1 - 3), where 4 arguments are reserved for the receiver, the lookup class, the name, and type. And `MethodHandle.invoke` is also limited, naturally by VM limitations. This limits the number of (static) arguments that may declared by a bootstrap method of an `invokedynamic` instruction and for the future dynamic constants (see JEP 309: Dynamic Class-File Constants, http://openjdk.java.net/jeps/309).


Solution
--------

Remove the arity limitation for `MethodHandle.invokeWithArguments` and specify bootstrap method invocation in terms of `MethodHandle.invokeWithArguments`.

In addition it has proved to provide utility method on MethodType, `MethodType.lastParameterType`, that is referred to in the specification.

Specification
-------------

See (and attached patch):
http://cr.openjdk.java.net/~psandoz/jdk10/JDK-8185992-invoke-with-arguments-jumbo/webrev/

(I would add inline, but the patch renders incorrectly.)

Comments
Yes, i updated the description.
08-01-2018

Moving to approved.
31-08-2017