57
57
*/
58
58
public class ConstructorReference extends SpelNodeImpl {
59
59
60
- private boolean isArrayConstructor = false ;
60
+ private final boolean isArrayConstructor ;
61
61
62
62
@ Nullable
63
63
private SpelNodeImpl [] dimensions ;
@@ -234,6 +234,7 @@ private TypedValue createArray(ExpressionState state) throws EvaluationException
234
234
FormatHelper .formatClassNameForMessage (
235
235
intendedArrayType != null ? intendedArrayType .getClass () : null ));
236
236
}
237
+
237
238
String type = (String ) intendedArrayType ;
238
239
Class <?> componentType ;
239
240
TypeCode arrayTypeCode = TypeCode .forName (type );
@@ -243,7 +244,8 @@ private TypedValue createArray(ExpressionState state) throws EvaluationException
243
244
else {
244
245
componentType = arrayTypeCode .getType ();
245
246
}
246
- Object newArray ;
247
+
248
+ Object newArray = null ;
247
249
if (!hasInitializer ()) {
248
250
// Confirm all dimensions were specified (for example [3][][5] is missing the 2nd dimension)
249
251
if (this .dimensions != null ) {
@@ -252,23 +254,22 @@ private TypedValue createArray(ExpressionState state) throws EvaluationException
252
254
throw new SpelEvaluationException (getStartPosition (), SpelMessage .MISSING_ARRAY_DIMENSION );
253
255
}
254
256
}
255
- }
256
- TypeConverter typeConverter = state . getEvaluationContext (). getTypeConverter ();
257
-
258
- // Shortcut for 1 dimensional
259
- if ( this . dimensions . length == 1 ) {
260
- TypedValue o = this . dimensions [ 0 ]. getTypedValue ( state );
261
- int arraySize = ExpressionUtils . toInt ( typeConverter , o );
262
- newArray = Array . newInstance ( componentType , arraySize );
263
- }
264
- else {
265
- // Multi-dimensional - hold onto your hat!
266
- int [] dims = new int [ this .dimensions . length ] ;
267
- for ( int d = 0 ; d < this . dimensions . length ; d ++) {
268
- TypedValue o = this . dimensions [ d ]. getTypedValue ( state );
269
- dims [ d ] = ExpressionUtils . toInt ( typeConverter , o );
257
+ TypeConverter typeConverter = state . getEvaluationContext (). getTypeConverter ();
258
+ if ( this . dimensions . length == 1 ) {
259
+ // Shortcut for 1-dimensional
260
+ TypedValue o = this . dimensions [ 0 ]. getTypedValue ( state );
261
+ int arraySize = ExpressionUtils . toInt ( typeConverter , o );
262
+ newArray = Array . newInstance ( componentType , arraySize );
263
+ }
264
+ else {
265
+ // Multi-dimensional - hold onto your hat!
266
+ int [] dims = new int [ this . dimensions . length ];
267
+ for ( int d = 0 ; d < this . dimensions . length ; d ++) {
268
+ TypedValue o = this .dimensions [ d ]. getTypedValue ( state ) ;
269
+ dims [ d ] = ExpressionUtils . toInt ( typeConverter , o );
270
+ }
271
+ newArray = Array . newInstance ( componentType , dims );
270
272
}
271
- newArray = Array .newInstance (componentType , dims );
272
273
}
273
274
}
274
275
else {
0 commit comments