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