@@ -279,7 +279,8 @@ static boolean convertArguments(TypeConverter converter, Object[] arguments, Exe
279
279
for (int i = 0 ; i < arguments .length ; i ++) {
280
280
TypeDescriptor targetType = new TypeDescriptor (MethodParameter .forExecutable (executable , i ));
281
281
Object argument = arguments [i ];
282
- arguments [i ] = converter .convertValue (argument , TypeDescriptor .forObject (argument ), targetType );
282
+ TypeDescriptor sourceType = TypeDescriptor .forObject (argument );
283
+ arguments [i ] = converter .convertValue (argument , sourceType , targetType );
283
284
conversionOccurred |= (argument != arguments [i ]);
284
285
}
285
286
}
@@ -288,7 +289,8 @@ static boolean convertArguments(TypeConverter converter, Object[] arguments, Exe
288
289
for (int i = 0 ; i < varargsPosition ; i ++) {
289
290
TypeDescriptor targetType = new TypeDescriptor (MethodParameter .forExecutable (executable , i ));
290
291
Object argument = arguments [i ];
291
- arguments [i ] = converter .convertValue (argument , TypeDescriptor .forObject (argument ), targetType );
292
+ TypeDescriptor sourceType = TypeDescriptor .forObject (argument );
293
+ arguments [i ] = converter .convertValue (argument , sourceType , targetType );
292
294
conversionOccurred |= (argument != arguments [i ]);
293
295
}
294
296
@@ -318,7 +320,7 @@ else if (!sourceType.isAssignableTo(componentTypeDesc)) {
318
320
// Possible outcomes of the above if-else block:
319
321
// 1) the input argument was null, and nothing was done.
320
322
// 2) the input argument was null; the varargs component type is Optional; and the argument was converted to Optional.empty().
321
- // 3) the input argument was correct type but not wrapped in an array, and nothing was done.
323
+ // 3) the input argument was the correct type but not wrapped in an array, and nothing was done.
322
324
// 4) the input argument was already compatible (i.e., array of valid type), and nothing was done.
323
325
// 5) the input argument was the wrong type and got converted and wrapped in an array.
324
326
if (argument != arguments [varargsPosition ] &&
@@ -364,7 +366,8 @@ public static boolean convertAllMethodHandleArguments(TypeConverter converter, O
364
366
TypeDescriptor targetType = new TypeDescriptor (resolvableType , argumentClass , null );
365
367
366
368
Object argument = arguments [i ];
367
- arguments [i ] = converter .convertValue (argument , TypeDescriptor .forObject (argument ), targetType );
369
+ TypeDescriptor sourceType = TypeDescriptor .forObject (argument );
370
+ arguments [i ] = converter .convertValue (argument , sourceType , targetType );
368
371
conversionOccurred |= (argument != arguments [i ]);
369
372
}
370
373
}
@@ -376,7 +379,8 @@ public static boolean convertAllMethodHandleArguments(TypeConverter converter, O
376
379
TypeDescriptor targetType = new TypeDescriptor (resolvableType , argumentClass , null );
377
380
378
381
Object argument = arguments [i ];
379
- arguments [i ] = converter .convertValue (argument , TypeDescriptor .forObject (argument ), targetType );
382
+ TypeDescriptor sourceType = TypeDescriptor .forObject (argument );
383
+ arguments [i ] = converter .convertValue (argument , sourceType , targetType );
380
384
conversionOccurred |= (argument != arguments [i ]);
381
385
}
382
386
@@ -407,9 +411,9 @@ else if (!sourceType.isAssignableTo(componentTypeDesc)) {
407
411
// Possible outcomes of the above if-else block:
408
412
// 1) the input argument was null, and nothing was done.
409
413
// 2) the input argument was null; the varargs component type is Optional; and the argument was converted to Optional.empty().
410
- // 3) the input argument was correct type but not wrapped in an array, and nothing was done.
411
- // 4) the input argument was already compatible (i.e., array of valid type), and nothing was done.
412
- // 5) the input argument was the wrong type and got converted and wrapped in an array .
414
+ // 3) the input argument was the correct type but not wrapped in an array, and nothing was done.
415
+ // 4) the input argument was already compatible (i.e., an Object array of valid type), and nothing was done.
416
+ // 5) the input argument was the wrong type and got converted as explained in the comments above .
413
417
if (argument != arguments [varargsPosition ] &&
414
418
!isFirstEntryInArray (argument , arguments [varargsPosition ])) {
415
419
conversionOccurred = true ; // case 5
@@ -419,7 +423,8 @@ else if (!sourceType.isAssignableTo(componentTypeDesc)) {
419
423
else {
420
424
for (int i = varargsPosition ; i < arguments .length ; i ++) {
421
425
Object argument = arguments [i ];
422
- arguments [i ] = converter .convertValue (argument , TypeDescriptor .forObject (argument ), componentTypeDesc );
426
+ TypeDescriptor sourceType = TypeDescriptor .forObject (argument );
427
+ arguments [i ] = converter .convertValue (argument , sourceType , componentTypeDesc );
423
428
conversionOccurred |= (argument != arguments [i ]);
424
429
}
425
430
}
0 commit comments