Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8186469

MethodHandle.invokeWithArguments jumbo-arity

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 10
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      There is a small risk that invocations that previously failed, with an exception due to the limit on the number of arguments, will no longer fail. This is more likely to impact tests.

      Note that invokedynamic has changed to use MH.invokeWithArguments instead of MH.invoke. However such invokedynamic invocation will be equivalent if the number of arguments is small. (The VM specification will be updated accordingly.)
      Show
      There is a small risk that invocations that previously failed, with an exception due to the limit on the number of arguments, will no longer fail. This is more likely to impact tests. Note that invokedynamic has changed to use MH.invokeWithArguments instead of MH.invoke. However such invokedynamic invocation will be equivalent if the number of arguments is small. (The VM specification will be updated accordingly.)
    • Java API, Other

    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.)

      Attachments

        Issue Links

          Activity

            People

              psandoz Paul Sandoz
              psandoz Paul Sandoz
              Doug Lea
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: