兼容TypeToken.typeToClass 方法

This commit is contained in:
Redkale
2019-10-26 16:03:36 +08:00
parent 7c05df3cfb
commit 33763af96c

View File

@@ -83,7 +83,8 @@ public abstract class TypeToken<T> {
if (type instanceof TypeVariable) return null;
if (type instanceof GenericArrayType) return Array.newInstance(typeToClass(((GenericArrayType) type).getGenericComponentType()), 0).getClass();
if (!(type instanceof ParameterizedType)) return null; //只能是null了
return typeToClass(((ParameterizedType) type).getOwnerType());
Type owner = ((ParameterizedType) type).getOwnerType();
return typeToClass(owner == null ? ((ParameterizedType) type).getRawType() : owner);
}
public static Type[] getGenericType(final Type[] types, final Type declaringClass) {