[code-reflection] RFR: Fix lambda bugs [v8]

Mourad Abbay mabbay at openjdk.org
Wed Sep 3 13:41:13 UTC 2025


On Mon, 1 Sep 2025 15:33:44 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:

>> src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 1037:
>> 
>>> 1035:                     if (sym.name.equals(names._this) || sym.name.equals(names._super)) {
>>> 1036:                         result = thisValue();
>>> 1037:                     } else if (top.localToOp.containsKey(sym)) {
>> 
>> The correct check would be to see if `sym.getConstValue() != null`, which is also what the discriminator used by `QuotedLambdaScanner`:
>> https://github.com/mabbay/babylon/blob/77f2c77957677a95115bc9c829809ea099e20080/src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java#L577C73-L577C87
>
> That check won't be enough, because for methods we don't register constant captured fields.
> We need to check that `sym.getConstValue() != null && isQuoted`

we may need to unify the approach between methods and lambdas. For now, we embed constant fields for lambdas but we don't do it for methods. We may also consider doing true constant folding.

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

PR Review Comment: https://git.openjdk.org/babylon/pull/532#discussion_r2319013715


More information about the babylon-dev mailing list