Skip to content

Fall back to interpreted SpEL when compilation fails - #37468

Open
linghengqian wants to merge 1 commit into
spring-projects:mainfrom
linghengqian:spel-check
Open

linghengqian wants to merge 1 commit into
spring-projects:mainfrom
linghengqian:spel-check

Conversation

@linghengqian

@linghengqian linghengqian commented Oct 13, 2026 •

Copy link
Copy Markdown
  • For Explore how to pre-compile SpEL expressions during AOT processing #29548 .
  • Fall back to interpreted SpEL when compilation fails.
    • Previously, in a native environment—whenever the compilerMode was set to MIXED or IMMEDIATE (e.g., due to a spring.expression.compiler.mode configuration or the parsing of an expression requiring compilation)—SpelCompiler would attempt to call defineClass to generate CompiledExpression00001 upon the 100th evaluation (for MIXED) or the 2nd evaluation (for IMMEDIATE). GraalVM would then throw an UnsupportedFeatureError (which is an Error, whereas the legacy code only caught Exception types); this caused the entire evaluation process to crash, resulting in the process receiving a raw internal Graal error.
    • With the changes, the scenario plays out as follows: compilation failures are suppressed and tracked via failedAttempts, expressions fall back to interpreted execution with correct results (verified: 15 OK), and MIXED mode stops attempting compilation after 100 failures—aligning with the JVM behavior where non-compilable expressions fall back to the interpreter. IMMEDIATE mode also no longer leaks raw errors.
    • defineClass succeeds as expected on the JVM, so the fallback path is not triggered, and the full :spring-expression:test suite passes.
    • When using -H:+RuntimeClassLoading + Preserve, defineClass succeeds; empirical testing confirms that CompiledExpression00001 is indeed generated and the compiled execution path is taken, ensuring the fallback logic is not inadvertently triggered.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 13, 2026
Signed-off-by: Qiheng He <linghengqian@outlook.com>
@linghengqian
linghengqian marked this pull request as ready for review October 13, 2026 10:00
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Oct 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants