[code-reflection] RFR: Determine if lambda operation originates from a method reference

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Apr 23 11:13:49 UTC 2024


On Mon, 22 Apr 2024 20:49:40 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

> Add a method to determines if a lambda operation could have originated from a method reference declared in Java source code.
> 
> Consider later generalizing to a lambda operation that may have originated from a lambda expression that only invokes another method, which may include the capturing of some or all method arguments.

src/java.base/share/classes/java/lang/reflect/code/op/CoreOps.java line 527:

> 525:          *     or uniquely depends on, the result of the referencing invoke operation.
> 526:          *     <li>If the lambda operation captures one value then the first operand corresponds
> 527:          *     to captured value, and subsequent operands of the referencing invocation

Suggestion:

         *     to captured the value, and subsequent operands of the referencing invocation

src/java.base/share/classes/java/lang/reflect/code/op/CoreOps.java line 532:

> 530:          *     operation are, or uniquely depend on, the lambda operation's parameters, in order.
> 531:          * </ol>
> 532:          * A value, V2, uniquely depends on another value, V1, if the graph of what V2 depends on

This reminds me of the definition of isomorphism in category theory

src/java.base/share/classes/java/lang/reflect/code/op/CoreOps.java line 543:

> 541:          * expression operation, otherwise empty.
> 542:          */
> 543:         public Optional<InvokeOp> isMethodReference() {

maybe drop the leading `is` (since we return the method reference)

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

PR Review Comment: https://git.openjdk.org/babylon/pull/60#discussion_r1576069231
PR Review Comment: https://git.openjdk.org/babylon/pull/60#discussion_r1576070836
PR Review Comment: https://git.openjdk.org/babylon/pull/60#discussion_r1576072258


More information about the babylon-dev mailing list