This commit is contained in:
Redkale
2020-05-30 17:42:28 +08:00
parent 557c2c7858
commit 84061cf60f

View File

@@ -84,7 +84,9 @@ public abstract class TypeToken<T> {
if (type instanceof GenericArrayType) return Array.newInstance(typeToClass(((GenericArrayType) type).getGenericComponentType()), 0).getClass();
if (!(type instanceof ParameterizedType)) return null; //只能是null了
Type owner = ((ParameterizedType) type).getOwnerType();
return typeToClass(owner == null ? ((ParameterizedType) type).getRawType() : owner);
Type raw = ((ParameterizedType) type).getRawType();
//A$B<C> owner=A raw=A$B, 所以内部类情况下使用owner是错误的
return typeToClass(raw != null ? raw : owner);
}
public static Type[] getGenericType(final Type[] types, final Type declaringClass) {