Merge branch '6.1.x'
This commit is contained in:
commit
c93598835c
|
|
@ -243,8 +243,7 @@ public class FunctionReference extends SpelNodeImpl {
|
||||||
// to be packaged in an array, in contrast to how method invocation works with
|
// to be packaged in an array, in contrast to how method invocation works with
|
||||||
// reflection.
|
// reflection.
|
||||||
int actualVarargsIndex = functionArgs.length - 1;
|
int actualVarargsIndex = functionArgs.length - 1;
|
||||||
if (actualVarargsIndex >= 0 && functionArgs[actualVarargsIndex].getClass().isArray()) {
|
if (actualVarargsIndex >= 0 && functionArgs[actualVarargsIndex] instanceof Object[] argsToUnpack) {
|
||||||
Object[] argsToUnpack = (Object[]) functionArgs[actualVarargsIndex];
|
|
||||||
Object[] newArgs = new Object[actualVarargsIndex + argsToUnpack.length];
|
Object[] newArgs = new Object[actualVarargsIndex + argsToUnpack.length];
|
||||||
System.arraycopy(functionArgs, 0, newArgs, 0, actualVarargsIndex);
|
System.arraycopy(functionArgs, 0, newArgs, 0, actualVarargsIndex);
|
||||||
System.arraycopy(argsToUnpack, 0, newArgs, actualVarargsIndex, argsToUnpack.length);
|
System.arraycopy(argsToUnpack, 0, newArgs, actualVarargsIndex, argsToUnpack.length);
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,8 @@ public abstract class ReflectionHelper {
|
||||||
for (int i = 0; i < arguments.length; i++) {
|
for (int i = 0; i < arguments.length; i++) {
|
||||||
TypeDescriptor targetType = new TypeDescriptor(MethodParameter.forExecutable(executable, i));
|
TypeDescriptor targetType = new TypeDescriptor(MethodParameter.forExecutable(executable, i));
|
||||||
Object argument = arguments[i];
|
Object argument = arguments[i];
|
||||||
arguments[i] = converter.convertValue(argument, TypeDescriptor.forObject(argument), targetType);
|
TypeDescriptor sourceType = TypeDescriptor.forObject(argument);
|
||||||
|
arguments[i] = converter.convertValue(argument, sourceType, targetType);
|
||||||
conversionOccurred |= (argument != arguments[i]);
|
conversionOccurred |= (argument != arguments[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +288,8 @@ public abstract class ReflectionHelper {
|
||||||
for (int i = 0; i < varargsPosition; i++) {
|
for (int i = 0; i < varargsPosition; i++) {
|
||||||
TypeDescriptor targetType = new TypeDescriptor(MethodParameter.forExecutable(executable, i));
|
TypeDescriptor targetType = new TypeDescriptor(MethodParameter.forExecutable(executable, i));
|
||||||
Object argument = arguments[i];
|
Object argument = arguments[i];
|
||||||
arguments[i] = converter.convertValue(argument, TypeDescriptor.forObject(argument), targetType);
|
TypeDescriptor sourceType = TypeDescriptor.forObject(argument);
|
||||||
|
arguments[i] = converter.convertValue(argument, sourceType, targetType);
|
||||||
conversionOccurred |= (argument != arguments[i]);
|
conversionOccurred |= (argument != arguments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -317,7 +319,7 @@ public abstract class ReflectionHelper {
|
||||||
// Possible outcomes of the above if-else block:
|
// Possible outcomes of the above if-else block:
|
||||||
// 1) the input argument was null, and nothing was done.
|
// 1) the input argument was null, and nothing was done.
|
||||||
// 2) the input argument was null; the varargs component type is Optional; and the argument was converted to Optional.empty().
|
// 2) the input argument was null; the varargs component type is Optional; and the argument was converted to Optional.empty().
|
||||||
// 3) the input argument was correct type but not wrapped in an array, and nothing was done.
|
// 3) the input argument was the correct type but not wrapped in an array, and nothing was done.
|
||||||
// 4) the input argument was already compatible (i.e., array of valid type), and nothing was done.
|
// 4) the input argument was already compatible (i.e., array of valid type), and nothing was done.
|
||||||
// 5) the input argument was the wrong type and got converted and wrapped in an array.
|
// 5) the input argument was the wrong type and got converted and wrapped in an array.
|
||||||
if (argument != arguments[varargsPosition] &&
|
if (argument != arguments[varargsPosition] &&
|
||||||
|
|
@ -363,7 +365,8 @@ public abstract class ReflectionHelper {
|
||||||
TypeDescriptor targetType = new TypeDescriptor(resolvableType, argumentClass, null);
|
TypeDescriptor targetType = new TypeDescriptor(resolvableType, argumentClass, null);
|
||||||
|
|
||||||
Object argument = arguments[i];
|
Object argument = arguments[i];
|
||||||
arguments[i] = converter.convertValue(argument, TypeDescriptor.forObject(argument), targetType);
|
TypeDescriptor sourceType = TypeDescriptor.forObject(argument);
|
||||||
|
arguments[i] = converter.convertValue(argument, sourceType, targetType);
|
||||||
conversionOccurred |= (argument != arguments[i]);
|
conversionOccurred |= (argument != arguments[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -375,7 +378,8 @@ public abstract class ReflectionHelper {
|
||||||
TypeDescriptor targetType = new TypeDescriptor(resolvableType, argumentClass, null);
|
TypeDescriptor targetType = new TypeDescriptor(resolvableType, argumentClass, null);
|
||||||
|
|
||||||
Object argument = arguments[i];
|
Object argument = arguments[i];
|
||||||
arguments[i] = converter.convertValue(argument, TypeDescriptor.forObject(argument), targetType);
|
TypeDescriptor sourceType = TypeDescriptor.forObject(argument);
|
||||||
|
arguments[i] = converter.convertValue(argument, sourceType, targetType);
|
||||||
conversionOccurred |= (argument != arguments[i]);
|
conversionOccurred |= (argument != arguments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -406,9 +410,9 @@ public abstract class ReflectionHelper {
|
||||||
// Possible outcomes of the above if-else block:
|
// Possible outcomes of the above if-else block:
|
||||||
// 1) the input argument was null, and nothing was done.
|
// 1) the input argument was null, and nothing was done.
|
||||||
// 2) the input argument was null; the varargs component type is Optional; and the argument was converted to Optional.empty().
|
// 2) the input argument was null; the varargs component type is Optional; and the argument was converted to Optional.empty().
|
||||||
// 3) the input argument was correct type but not wrapped in an array, and nothing was done.
|
// 3) the input argument was the correct type but not wrapped in an array, and nothing was done.
|
||||||
// 4) the input argument was already compatible (i.e., array of valid type), and nothing was done.
|
// 4) the input argument was already compatible (i.e., an Object array of valid type), and nothing was done.
|
||||||
// 5) the input argument was the wrong type and got converted and wrapped in an array.
|
// 5) the input argument was the wrong type and got converted as explained in the comments above.
|
||||||
if (argument != arguments[varargsPosition] &&
|
if (argument != arguments[varargsPosition] &&
|
||||||
!isFirstEntryInArray(argument, arguments[varargsPosition])) {
|
!isFirstEntryInArray(argument, arguments[varargsPosition])) {
|
||||||
conversionOccurred = true; // case 5
|
conversionOccurred = true; // case 5
|
||||||
|
|
@ -418,7 +422,8 @@ public abstract class ReflectionHelper {
|
||||||
else {
|
else {
|
||||||
for (int i = varargsPosition; i < arguments.length; i++) {
|
for (int i = varargsPosition; i < arguments.length; i++) {
|
||||||
Object argument = arguments[i];
|
Object argument = arguments[i];
|
||||||
arguments[i] = converter.convertValue(argument, TypeDescriptor.forObject(argument), componentTypeDesc);
|
TypeDescriptor sourceType = TypeDescriptor.forObject(argument);
|
||||||
|
arguments[i] = converter.convertValue(argument, sourceType, componentTypeDesc);
|
||||||
conversionOccurred |= (argument != arguments[i]);
|
conversionOccurred |= (argument != arguments[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue