← Back to Pull requests

feat: desugar lambdas in aot-bytecode, an opt-in step for starts without a JDK AOT cache #527

Closed
unknown closed this pull request without merging on Oct 13, 2026 13:52 UTC
View on GitHub
unknown unknown commented on Oct 07, 2026 21:55 UTC
Author

What. desugarLambdas(true), a second opt-in step of ClassPathTransform, turns each LambdaMetafactory.metafactory site into a call to a class generated next to its host. Sites of one host with the same interface, method and captures share a class, as in micronaut-projects/micronaut-build#957.

Why. Without a JDK AOT cache, every start spins a hidden class per lambda it reaches, mostly in dependencies (#521).

How. Runner's desugarer (alvarosanchez/micronaut-runner@6363090) on an open class path, where uncertain names stay. A site also stays when its interface's initializer could reach it first, as core's ConversionContext does. Plugins call desugarLambdas(true); Runner (#250) adds foreignPackages(Set.of("io.micronaut.runner")).

Tests. 121 unit tests, which fail to compile on 3406ef4 and catch 45 mutations; "Class path corpus" also starts an app under -Xverify:all (with -cp).

Results (Apple M4 Pro, 12 CPUs, 48 GB; JDK 25; Micronaut 5.1.5; Docker's Linux VM). Readiness unless RSS, % [95% CI], 3 sessions × 20 pairs (cached: 12 caches), timed at 1e51b2b, which rewrote 2 more sites per app; data-security held out.

| | hello-netty | benchmark-large | data-security |
|---|---|---|---|
| Fat JAR, no cache | −8.2 [−8.7, −7.5] | −7.6 [−8.3, −7.3] | −7.5 [−7.9, −6.7] |
| Docker layout, 2 CPUs | −8.9 [−9.9, −8.1] | −7.3 [−8.3, −6.9] | −5.3 [−5.8, −4.8] |
| Fat JAR, AOT cache | +0.8 [+0.2, +1.4] | +0.7 [+0.2, +1.2] | −1.3 [−1.5, −1.1] |
| RSS, Docker layout, 2 CPUs | −2.2 [−2.7, −1.7] | −3.6 [−3.8, −3.3] | −6.3 [−6.6, −5.8] |

JDK 27 agrees without a cache. One class per site (3de85df): −5.7, −5.9, −4.7; cached +1.7, +1.3.

Criteria of #521

  • No-cache fat JAR faster in every session: met.

  • At most 25 non-JDK lambda sites linked: met, 1 (542 before).

  • Every artifact starts under -Xverify:all; no class verifies worse: met.

  • Size: fat JARs +8.8 to +9.5% (each JAR +0.2 to +44%); STORED +6.7 to +7.1% (Runner per site: +9.8%).

  • Cost: 0.6 s fresh, 0.2 s warm (benchmark-large, 12 threads).
  • Open questions
    1. Shared classes follow #957, not reviewed yet.
    2. No closedClassPath: open mode rewrites Runner's sites here, but for the initializer rule's 2 per app; the 2 extra shadowedOrUncertain are reactor-core's multi-release base copy.
    3. Cached: +0.7–0.8% on JDK 25 with 5.1.5; not significant on JDK 27, nor with micronaut-projects/micronaut-core#13650 and #957's modules. Acceptable?
    4. Docs: a section of classPathTransform.adoc.

    Fixes #521

    🤖 Generated with Claude Code

    Diff: 323 lines (+242 / -81) across 4 files Reviewer: alvarosanchez Review duration: 8156m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 323 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.346
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #527"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.0% (MEDIUM) · Higher = larger blast radius
    42.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.6% · Safe to merge
    16.6%