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

Add a dropReturn MethodHandle combinator

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 16
    • Fix Version/s: 16
    • Component/s: core-libs
    • Labels:
      None

      Description

      Add a method to MethodHandles, like:

          public static MethodHandle dropReturn(MethodHandle target)

      That can be used to drop the return value of a MethodHandle.

      Doing this is currently already possible with the following code:

              MethodHandle target = ...;
              Class<?> targetReturnType = target.type().returnType();
              if (targetReturnType == void.class)
                  return target;
              return filterReturnValue(target, empty(methodType(void.class, targetReturnType)));

      But, a combinator can be provided as a short-hand.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jvernee Jorn Vernee
              Reporter:
              jvernee Jorn Vernee
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: