-
CSR
-
Resolution: Approved
-
P4
-
None
-
behavioral
-
minimal
-
Since this is a new API, whose implementation doesn't change any existing code, there is virtually no compatibility risk.
-
Java API
-
SE
Summary
Add a dropReturn method handle combinator, that can be used to drop the return value of a method handle.
Problem
There are currently several methods in j.l.i.MethodHandles for dropping arguments, but a similar combinator does not exist for dropping return values. Instead other means such as using a combination of filterReturn and empty, or asType with a void return type have to be used to create a method handle that discards the return value.
Solution
Provide a dropReturn method handle combinator that takes a MethodHandle, and returns a new MethodHandle that is the same as the given method handle, but which discards it's return value.
Specification
/**
* Drop the return value of the target handle (if any).
* The returned method handle will have a {@code void} return type.
*
* @param target the method handle to adapt
* @return a possibly adapted method handle
* @throws NullPointerException if {@code target} is null
* @since 16
*/
public static MethodHandle dropReturn(MethodHandle target) {
...
}
- csr of
-
JDK-8255374 Add a dropReturn MethodHandle combinator
-
- Resolved
-
- links to
-
Review openjdk/jdk/866