RFR: 8310157: Allow void-returning filters for MethodHandles::collectCoordinates

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Jun 16 00:35:00 UTC 2023


On Thu, 15 Jun 2023 15:44:04 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> This patch changes the implementation of `MethodHandles::collectCoordinates` to allow using filters that return `void`. This brings the behavior in line with the previously existing `MethodHandles::collectArgument` which operates on MethodHandles rather than VarHandles.
> 
> Testing: jdk-tier1,2,3

Looks good (thanks for taking care of this). The javadoc can probably be consolidated a bit further.

src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 8191:

> 8189:      * coordinate list.
> 8190:      * <p>
> 8191:      * If {@code R} is the return type of the filter, then, unless {@code R} is void, the target var handle must accept

Not introduced by you - but this para seems to be repeated twice-ish. I think we should try to consolidate the two, if we can.

src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 8203:

> 8201:      * If the return type of the filter is <em>not</em> void, it must be identical to the
> 8202:      * coordinate type of the target var handle at position {@code pos}, and that target var handle
> 8203:      * coordinate is supplied by the return value of the filter. If the return type of the filter <em>is</em> void,

This is the other para I was talking about in the other comment.

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

Marked as reviewed by mcimadamore (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/14496#pullrequestreview-1482554155
PR Review Comment: https://git.openjdk.org/jdk/pull/14496#discussion_r1231654844
PR Review Comment: https://git.openjdk.org/jdk/pull/14496#discussion_r1231654864


More information about the core-libs-dev mailing list