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

Add a dropReturn MethodHandle combinator

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • 16
    • 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.

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

              Created:
              Updated:
              Resolved: