mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix:ReflectUtil.invokeRaw 对于类型不同的字段,尝试转换,转换失败则使用原对象类型
This commit is contained in:
parent
1ae03284e8
commit
5189fa52dd
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user