Skip to content

Commit 528029a

Browse files
committed
Document that SpEL expressions using array construction cannot be compiled
Closes gh-32401
1 parent fea1464 commit 528029a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

framework-docs/modules/ROOT/pages/core/expressions/evaluation.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ following kinds of expressions cannot be compiled.
518518
* Expressions relying on the conversion service
519519
* Expressions using custom resolvers or accessors
520520
* Expressions using overloaded operators
521+
* Expressions using array construction syntax
521522
* Expressions using selection or projection
522523

523524
Compilation of additional kinds of expressions may be supported in the future.

framework-docs/modules/ROOT/pages/core/expressions/language-ref/array-construction.adoc

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Java::
1313
int[] numbers1 = (int[]) parser.parseExpression("new int[4]").getValue(context);
1414
1515
// Array with initializer
16-
int[] numbers2 = (int[]) parser.parseExpression("new int[]{1,2,3}").getValue(context);
16+
int[] numbers2 = (int[]) parser.parseExpression("new int[] {1, 2, 3}").getValue(context);
1717
1818
// Multi dimensional array
1919
int[][] numbers3 = (int[][]) parser.parseExpression("new int[4][5]").getValue(context);
@@ -26,14 +26,22 @@ Kotlin::
2626
val numbers1 = parser.parseExpression("new int[4]").getValue(context) as IntArray
2727
2828
// Array with initializer
29-
val numbers2 = parser.parseExpression("new int[]{1,2,3}").getValue(context) as IntArray
29+
val numbers2 = parser.parseExpression("new int[] {1, 2, 3}").getValue(context) as IntArray
3030
3131
// Multi dimensional array
3232
val numbers3 = parser.parseExpression("new int[4][5]").getValue(context) as Array<IntArray>
3333
----
3434
======
3535

36+
[NOTE]
37+
====
3638
You cannot currently supply an initializer when you construct a multi-dimensional array.
37-
38-
39-
39+
====
40+
41+
[CAUTION]
42+
====
43+
Any expression that constructs an array – for example, via `new int[4]` or
44+
`new int[] {1, 2, 3}` – cannot be compiled. See
45+
xref:core/expressions/evaluation.adoc#expressions-compiler-limitations[Compiler Limitations]
46+
for details.
47+
====

0 commit comments

Comments
 (0)