mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复JsonUtil.toBean
泛型数组类型丢失问题(pr#3876@Github)
This commit is contained in:
@@ -418,7 +418,7 @@ public class TypeUtil {
|
||||
* 2. 泛型变量,类似于T
|
||||
* </pre>
|
||||
*
|
||||
* @param type 类
|
||||
* @param type 泛型类
|
||||
* @param typeVariable 泛型变量,例如T等
|
||||
* @return 实际类型,可能为Class等
|
||||
*/
|
||||
@@ -431,7 +431,10 @@ public class TypeUtil {
|
||||
}
|
||||
// pr#3876 解决泛型数组泛型类型无法识别问题
|
||||
if (typeVariable instanceof GenericArrayType) {
|
||||
return ActualTypeMapperPool.getActualType(type, (GenericArrayType) typeVariable);
|
||||
final Type actualType = ActualTypeMapperPool.getActualType(type, (GenericArrayType) typeVariable);
|
||||
if(null != actualType){
|
||||
return actualType;
|
||||
}
|
||||
}
|
||||
|
||||
// 没有需要替换的泛型变量,原样输出
|
||||
|
@@ -30,6 +30,11 @@ import java.util.Objects;
|
||||
*/
|
||||
class ClassUtilTest {
|
||||
|
||||
@Test
|
||||
void forNameTest() {
|
||||
Assertions.assertEquals(String.class, ClassUtil.forName("java.lang.String", false, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetSuperClasses() {
|
||||
// if root is null
|
||||
|
Reference in New Issue
Block a user