RFR: 8255398: Add a dropReturn MethodHandle combinator

Jorn Vernee jvernee at openjdk.java.net
Mon Oct 26 15:37:20 UTC 2020


Hi,

This patch adds a `dropReturn` combinator to `MethodHandles` that can be used to create a new method handle that drops the return value, from a given method handle. Similar to the following code:

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

But as a short-hand.

Thanks,
Jorn

-------------

Commit messages:
 - Add a dropReturn method handle combinator

Changes: https://git.openjdk.java.net/jdk/pull/866/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=866&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8255398
  Stats: 92 lines in 2 files changed: 92 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/866.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/866/head:pull/866

PR: https://git.openjdk.java.net/jdk/pull/866


More information about the core-libs-dev mailing list