Compiled SpEL expression fails if #root
or #this
is a non-public type
#32356
Labels
Milestone
#root
or #this
is a non-public type
#32356
If a SpEL expression references the root context object via the
#root
or#this
variables, we currently insert acheckcast
in the generated byte code that casts the object to its concrete type.However if the root context object's type is non-public, that results in an
IllegalAccessError
when the compiled byte code is executed.See the following test, for an example.
spring-framework/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java
Lines 514 to 525 in a29c84f
Interestingly enough,
VariableReference.getValueInternal(ExpressionState)
already contains a "workaround" for global variables which inserts acheckcast
toObject
in the generated byte code instead of to the object's concrete non-public type.I have a local fix that applies the same logic to
#root
/#this
and global variables. Thus, this issue is here to provide public visibility and raise awareness.The text was updated successfully, but these errors were encountered: