[code-reflection] RFR: Add isQuotable attribute to LambdaOp [v5]

Paul Sandoz psandoz at openjdk.org
Mon Sep 8 22:38:19 UTC 2025


On Mon, 8 Sep 2025 21:52:44 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:

>> In the `interpreter` and `ByteCodeGenerator` we detect if a lambda is quotable based on its functional interface. This approach will not work if intersection type is used e.g. `Runnable r = (Runnable & Quotable) () -> {};` This PR adds a flag to LambdaOp that will be set by the `javac` for quotable lambdas.
>
> Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Rectify the way we get the flags of a lambda invokedynamic

src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/BytecodeLift.java line 478:

> 476:                                                                        lambdaFunc,
> 477:                                                                        JavaType.type(inst.typeSymbol().returnType()));
> 478:                         // if FLAG_QUOTABLE is set, the lambda is quotable

I think it would be clearer if you check that the bootstrap method name is `altMetafactory` then it should be guaranteed there will be at least four arguments (otherwise the bytecode is not valid) e.g.,

if (bsm.methodName().equals("altMetafactory") {
    assert inst.bootstrapArgs().size() > 3;
    assert inst.bootstrapArgs().get(3) instanceof Integer;

    if (inst.bootstrapArgs().get(3) instanceof int flags
            && (flags & LambdaMetafactory.FLAG_QUOTABLE) != 0) {
        lambda = lambda.quotable();
    }
}

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

PR Review Comment: https://git.openjdk.org/babylon/pull/545#discussion_r2331480577


More information about the babylon-dev mailing list