Open quaff opened 1 month ago
Hi @quaff,
This is the expected behavior for the IMMEDIATE
compiler mode.
I think we should recompile if possible whilst registered variable type changing detected
We don't actually detect any changes in the types. Rather, the expression is compiled against a single set of types (determined during the initial reflective evaluation of the expression), and any subsequent invocation of the compiled expression fails if the there is a type mismatch in the compiled byte code.
Or document this limitation on javadoc of
IMMEDIATE
.
The Javadoc currently states:
If a compiled expression fails it will throw an exception to the caller.
And the Javadoc for MIXED
goes into more detail.
Though, I agree that similar information should be added to the Javadoc for IMMEDIATE
.
In light of that, I changed the title of this issue and assigned it the documentation
label.
Generally speaking, one should avoid compilation of SpEL expressions for which types are expected to change behind the scenes, since that defeats the goal of static compilation. See also: https://github.com/spring-projects/spring-framework/issues/28043#issuecomment-1044640271
Here is test case
I think we should recompile if possible whilst registered variable type changing detected, Or document this limitation on javadoc of
IMMEDIATE
.Related to https://github.com/spring-projects/spring-framework/issues/28043