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

Add a dropReturn MethodHandle combinator

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 16
    • 16
    • core-libs
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: