fix:ReflectUtil.invokeRaw 对于类型不同的字段,尝试转换,转换失败则使用原对象类型

This commit is contained in:
xudeping 2022-10-14 17:33:00 +08:00
parent 1ae03284e8
commit 5189fa52dd

View File

@ -846,7 +846,7 @@ public class ReflectUtil {
public static <T> T newInstance(Class<T> clazz, Object... params) throws UtilException {
if (ArrayUtil.isEmpty(params)) {
final Constructor<T> constructor = getConstructor(clazz);
if(null == constructor){
if (null == constructor) {
throw new UtilException("No constructor for [{}]", clazz);
}
try {
@ -1056,7 +1056,7 @@ public class ReflectUtil {
actualArgs[i] = null;
} else if (false == parameterTypes[i].isAssignableFrom(args[i].getClass())) {
//对于类型不同的字段尝试转换转换失败则使用原对象类型
final Object targetValue = Convert.convert(parameterTypes[i], args[i]);
final Object targetValue = Convert.convertQuietly(parameterTypes[i], args[i], args[i]);
if (null != targetValue) {
actualArgs[i] = targetValue;
}