[code-reflection] RFR: BytecodeGenerator support of lambdas
Paul Sandoz
psandoz at openjdk.org
Thu Apr 11 22:38:49 UTC 2024
On Tue, 9 Apr 2024 13:45:11 GMT, Adam Sotona <asotona at openjdk.org> wrote:
> BytecodeGenerator support of lambdas
src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeGenerator.java line 107:
> 105: MethodHandles.Lookup hcl;
> 106: try {
> 107: hcl = l.in(l.defineClass(classBytes));
That's frustrating! but thankfully its easy to work around it
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.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/48#discussion_r1561816094
PR Review Comment: https://git.openjdk.org/babylon/pull/48#discussion_r1561823663
More information about the babylon-dev
mailing list