From d6ba4a1ab7a45e5896e6baaac78a70de4c9b5af5 Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Thu, 8 Feb 2018 14:41:02 +0800 Subject: [PATCH] --- src/org/redkale/util/TypeToken.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/org/redkale/util/TypeToken.java b/src/org/redkale/util/TypeToken.java index a734e283b..895de030b 100644 --- a/src/org/redkale/util/TypeToken.java +++ b/src/org/redkale/util/TypeToken.java @@ -69,11 +69,17 @@ public abstract class TypeToken { if (type instanceof TypeVariable) { if (declaringClass instanceof Class) { final Class declaringClass0 = (Class) declaringClass; - final Type superType = declaringClass0.getGenericSuperclass(); + Type superType = declaringClass0.getGenericSuperclass(); + while (superType instanceof Class && superType != Object.class) superType = ((Class) superType).getGenericSuperclass(); if (superType instanceof ParameterizedType) { ParameterizedType superPT = (ParameterizedType) superType; Type[] atas = superPT.getActualTypeArguments(); - TypeVariable[] asts = declaringClass0.getSuperclass().getTypeParameters(); + Class ss = declaringClass0; + TypeVariable[] asts = ss.getTypeParameters(); + while (atas.length != asts.length && ss != Object.class) { + ss = ss.getSuperclass(); + asts = ss.getTypeParameters(); + } if (atas.length == asts.length) { for (int i = 0; i < asts.length; i++) { if (asts[i] == type) return atas[i];