[code-reflection] Integrated: Split support for reflectable lambdas from lambda metafactory

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Nov 20 22:07:39 UTC 2025


On Thu, 20 Nov 2025 18:59:06 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This PR introduces a new class, called `ReflectableLambdaMetafactory`, which lives in the incubating code reflection module.
> 
> All capture requests for reflectable lambdas are now re-routed by javac to the new bootstrap methods defined in this class. This allows us to evolve the bootstrap protocol for reflectable lambda without negatively affecting other, non-reflectable lambdas (esp. at startup).
> 
> Some magic was required to wire up the pieces: javac cannot refer to symbols in the incubating module, so I decided to let `ReflectMethods` leave a trail of crumbs for `LambdaToMethod` to go on (as `LambdaToMethod` needs to know the name of the class in which the bootstrap method lives).
> 
> Some restructuring to `LambdaMetafactory` was also necessary, so that we could access the implementation internals from the new class. The new `xyzInternal` methods are exposed through `SharedSecrects` and are invoked by the reflectable metafactory, which also passes up extra information that the metafactory implementation needs to generate the additional code for reflectable lambdas.
> 
> This also allowed me to get rid of the `CodeReflectionSupport` class in `InnerClassLambdaMetafactory` and the related module layer dance.

This pull request has now been integrated.

Changeset: b4c737c2
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/babylon/commit/b4c737c231f542fae345489168bb8d7f896e75b3
Stats:     517 lines in 14 files changed: 357 ins; 102 del; 58 mod

Split support for reflectable lambdas from lambda metafactory

Reviewed-by: psandoz

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

PR: https://git.openjdk.org/babylon/pull/688


More information about the babylon-dev mailing list