Skip to content

Commit

Permalink
Document that SpEL expressions using array construction cannot be com…
Browse files Browse the repository at this point in the history
…piled

Closes gh-32401
  • Loading branch information
sbrannen committed Mar 8, 2024
1 parent fea1464 commit 528029a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ following kinds of expressions cannot be compiled.
* Expressions relying on the conversion service
* Expressions using custom resolvers or accessors
* Expressions using overloaded operators
* Expressions using array construction syntax
* Expressions using selection or projection

Compilation of additional kinds of expressions may be supported in the future.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Java::
int[] numbers1 = (int[]) parser.parseExpression("new int[4]").getValue(context);
// Array with initializer
int[] numbers2 = (int[]) parser.parseExpression("new int[]{1,2,3}").getValue(context);
int[] numbers2 = (int[]) parser.parseExpression("new int[] {1, 2, 3}").getValue(context);
// Multi dimensional array
int[][] numbers3 = (int[][]) parser.parseExpression("new int[4][5]").getValue(context);
Expand All @@ -26,14 +26,22 @@ Kotlin::
val numbers1 = parser.parseExpression("new int[4]").getValue(context) as IntArray
// Array with initializer
val numbers2 = parser.parseExpression("new int[]{1,2,3}").getValue(context) as IntArray
val numbers2 = parser.parseExpression("new int[] {1, 2, 3}").getValue(context) as IntArray
// Multi dimensional array
val numbers3 = parser.parseExpression("new int[4][5]").getValue(context) as Array<IntArray>
----
======

[NOTE]
====
You cannot currently supply an initializer when you construct a multi-dimensional array.



====

[CAUTION]
====
Any expression that constructs an array – for example, via `new int[4]` or
`new int[] {1, 2, 3}` – cannot be compiled. See
xref:core/expressions/evaluation.adoc#expressions-compiler-limitations[Compiler Limitations]
for details.
====

0 comments on commit 528029a

Please sign in to comment.