Skip to content

Commit b8b16fa

Browse files
committed
find correct component type when the enclosing type is Foo<int[]> on JDK 7 and beyond
1 parent 6bab637 commit b8b16fa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ReflectUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ public static Class<?> getGenericClass(Class<?> cls, int i) {
261261
return (Class<?>) ((ParameterizedType) genericClass).getRawType();
262262
} else if (genericClass instanceof GenericArrayType) { // 处理数组泛型
263263
return (Class<?>) ((GenericArrayType) genericClass).getGenericComponentType();
264+
} else if (((Class)genericClass).isArray()) {
265+
// 在 JDK 7 以上的版本, Foo<int[]> 不再是 GenericArrayType
266+
return ((Class)genericClass).getComponentType();
264267
} else {
265268
return (Class<?>) genericClass;
266269
}

0 commit comments

Comments
 (0)