mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
fix(去除sun包): 去除sun包,兼容其他版本jdk
This commit is contained in:
@@ -3,10 +3,10 @@ package com.fastbee.base.core.hanler;
|
||||
import com.fastbee.common.core.protocol.Message;
|
||||
import com.fastbee.base.session.Session;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 基础处理类
|
||||
@@ -44,8 +44,21 @@ public abstract class BaseHandler {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
Type type = types[i];
|
||||
Class<?> clazz;
|
||||
if (type instanceof ParameterizedTypeImpl) {
|
||||
clazz = (Class<?>) ((ParameterizedTypeImpl) type).getActualTypeArguments()[0];
|
||||
if (type instanceof ParameterizedType) {
|
||||
ParameterizedType pt = (ParameterizedType) type;
|
||||
// 检查是否为List/Collection等容器类型
|
||||
if (pt.getRawType() instanceof Class &&
|
||||
((Class<?>) pt.getRawType()).isArray() ||
|
||||
Collection.class.isAssignableFrom((Class<?>) pt.getRawType())) {
|
||||
Type[] actualTypes = pt.getActualTypeArguments();
|
||||
if (actualTypes.length > 0) {
|
||||
clazz = (Class<?>) actualTypes[0];
|
||||
} else {
|
||||
clazz = Object.class; // 默认类型
|
||||
}
|
||||
} else {
|
||||
clazz = (Class<?>) pt.getRawType(); // 处理非容器类型的参数化类型
|
||||
}
|
||||
} else {
|
||||
clazz = (Class<?>) type;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user