Here you can find the source of getGenericSuperclass(Class> clazz)
@SuppressWarnings("rawtypes") public static Class[] getGenericSuperclass(Class<?> clazz)
//package com.java2s; //License from project: LGPL import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { @SuppressWarnings("rawtypes") public static Class[] getGenericSuperclass(Class<?> clazz) { try {/*w ww . j ava 2 s . co m*/ Type typeGeneric = clazz.getGenericSuperclass(); if (typeGeneric != null) { if (typeGeneric instanceof ParameterizedType) { return getGeneric((ParameterizedType) typeGeneric); } } } catch (Exception e) { } return null; } @SuppressWarnings("rawtypes") public static Class[] getGeneric(ParameterizedType type) { try { if (type != null) { Type[] typeArgs = type.getActualTypeArguments(); if (typeArgs != null && typeArgs.length > 0) { Class[] args = new Class[typeArgs.length]; for (int i = 0; i < typeArgs.length; i++) { Type arg = typeArgs[i]; args[i] = (Class) arg; } return args; } } } catch (Exception e) { } return null; } }