Add a dropReturn MethodHandle combinator

XMLWordPrintable

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

      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.

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

              Created:
              Updated:
              Resolved: