[code-reflection] RFR: BytecodeGenerator support of lambdas
Adam Sotona
asotona at openjdk.org
Fri Apr 12 07:22:59 UTC 2024
On Thu, 11 Apr 2024 22:36:32 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
>> BytecodeGenerator support of lambdas
>
> src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeGenerator.java line 741:
>
>> 739: for (Value cv : op.capturedValues()) {
>> 740: load(cv);
>> 741: }
>
> You should only need that when the resolved functional interface class is assignable to `Quotable`. This code appears to be quoting all lambdas?
>
> In your test code you have a functional interface `Func` but it does not extend from `Quotable`, so when generating the bytecode you don't need to apply the quoting logic for lambda expressions targeted to that interface. The test could should be expanded ti also include say `interface FuncQuotable extends FuncQuotable { ... }`, and from such instances their code model can be obtained.
Yes, now it is quoting all lambdas.
We may restrict it to interfaces explicitly extending `Quotable`.
Or we may use the ability of `LMF` to inject additional interfaces and make all lambdas generated from code models as `Quotable`.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/48#discussion_r1562135311
More information about the babylon-dev
mailing list