[code-reflection] RFR: Split support for reflectable lambdas from lambda metafactory
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Nov 20 19:06:51 UTC 2025
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.
-------------
Commit messages:
- Cleanup InnerClassLambdaMetafactory
- Fix JDK tests
- Split metafactories
- Use special encoding in lambda name to smuggle quotable lambdas
- Fix bootstrapping issues
- Initial push
Changes: https://git.openjdk.org/babylon/pull/688/files
Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=688&range=00
Stats: 517 lines in 14 files changed: 357 ins; 102 del; 58 mod
Patch: https://git.openjdk.org/babylon/pull/688.diff
Fetch: git fetch https://git.openjdk.org/babylon.git pull/688/head:pull/688
PR: https://git.openjdk.org/babylon/pull/688
More information about the babylon-dev
mailing list