[code-reflection] RFR: Drop support for quoted structural lambdas [v2]
Paul Sandoz
psandoz at openjdk.org
Thu Nov 6 18:04:32 UTC 2025
On Thu, 6 Nov 2025 15:29:20 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> The Babylon compiler extension supports structural quoting of lambdas. That is, if a lambda expression has `Quoted` target, then it must have explicit parameter types, and must be type-checked bottom up:
>>
>>
>> Quoted q = () -> {}
>>
>>
>> Historically, `Quoted` was the first way to model quotable lambda expressions, and the language changes to support structural quotable lambdas were fairly invasive. Since then we moved to a more minimalistic approach which is similar to what we do for serializable lambdas: we use an intersection type cast to force quotability of the lambda expression:
>>
>>
>> Runnable r = (Runnable & Quotable)() -> {}
>>
>>
>> Since the surface area of the `Quotable` support is much smaller (it shares the same machinery already available for serializable lambdas), it would be better to remove support for Quoted target when moving towards incubation.
>>
>> This PR fixes all existing tests in langtools/JDK to use `Quotable` instead of `Quoted`. I did **not** check HAT, or `cr-examples`.
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>
> Re-add accidentally deleted test
Very good! Really simplifies things.
The examples and HAT do not target lambda expressions to `Quoted`, so no updates required.
To support targeting to `Quoted` we had to add `ClosureOp` and `ClosureCallOp`. We could also remove these too, and their use in the interpreter (the byte code generator never used them).
test/jdk/java/lang/reflect/code/bytecode/TestQuoted.java line 49:
> 47: @Test
> 48: public void testQuoted() throws Throwable {
> 49: Quotable q = (IntBinaryOperator & Quotable)(int i, int j) -> {
We can delete this test, as there are others testing lambda expressions.
-------------
PR Review: https://git.openjdk.org/babylon/pull/667#pullrequestreview-3429706209
PR Review Comment: https://git.openjdk.org/babylon/pull/667#discussion_r2500178383
More information about the babylon-dev
mailing list