Ensure SpEL can compile an expression indexing into a boolean array
Closes gh-32400
This commit is contained in:
@@ -245,6 +245,12 @@ public class Indexer extends SpelNodeImpl {
|
||||
}
|
||||
case "B" -> {
|
||||
mv.visitTypeInsn(CHECKCAST, "[B");
|
||||
// byte and boolean arrays are both loaded via BALOAD
|
||||
yield BALOAD;
|
||||
}
|
||||
case "Z" -> {
|
||||
mv.visitTypeInsn(CHECKCAST, "[Z");
|
||||
// byte and boolean arrays are both loaded via BALOAD
|
||||
yield BALOAD;
|
||||
}
|
||||
case "C" -> {
|
||||
|
||||
@@ -308,6 +308,18 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("C");
|
||||
}
|
||||
|
||||
@Test
|
||||
void indexIntoPrimitiveBooleanArray() {
|
||||
boolean[] booleans = { true, false };
|
||||
|
||||
expression = parser.parseExpression("[1]");
|
||||
|
||||
assertThat(expression.getValue(booleans)).isEqualTo(false);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(booleans)).isEqualTo(false);
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
void indexIntoStringArray() {
|
||||
String[] strings = { "a", "b", "c" };
|
||||
|
||||
Reference in New Issue
Block a user