[code-reflection] RFR: Fix lambda bugs [v8]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Sep 1 10:16:03 UTC 2025
On Fri, 29 Aug 2025 21:36:15 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
>> Fix lambda bugs:
>> 1. Unnecessary load of static fields accessed inside the lambda body (bug 1).
>> 2. The model of a lambda expression that returns void, contains additional boxing whose result is not used (bug 2).
>> 3. Inner lambda is incorrectly quoted (bug 3).
>
> Mourad Abbay has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 10 additional commits since the last revision:
>
> - Merge branch 'code-reflection' into lambda-bugs
> - Apply review comments
> - Clarify comment
> - Fix bug 3
> - Add test cases to ensure bug 2 is fixed
> - Fix bug 2
> - Fix the bug of lambda model containing ReturnOp with value even though the lambda return type is void
> - Add test case to ensure bug 1 is fixed
> - Merge branch 'code-reflection' into lambda-bugs
> - Fix lambda bug 1
src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 1484:
> 1482: // thus the condition (... body == tree)
> 1483: // @@@ better name for isQuoted ?
> 1484: boolean toQuote = (isQuoted && body == tree) || kind == FunctionalExpressionKind.QUOTED_STRUCTURAL;
Nice (and subtle!) fix
src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 1504:
> 1502: Type lambdaReturnType = tree.getDescriptorType(types).getReturnType();
> 1503: if (tree.getBodyKind() == LambdaExpressionTree.BodyKind.EXPRESSION) {
> 1504: Value exprVal = toValue(((JCExpression) tree.body), lambdaReturnType);
I'd be tempted to check for `void` even before calling `toValue` -- it's a bit odd that we have to explicitly check for `VOID` in `coerce`
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/532#discussion_r2313525066
PR Review Comment: https://git.openjdk.org/babylon/pull/532#discussion_r2313526957
More information about the babylon-dev
mailing list