Java Reflection Generic Type from Class getGenericsClass(Class cls)

Here you can find the source of getGenericsClass(Class cls)

Description

get Generics Class

License

Apache License

Declaration

public static Class getGenericsClass(Class cls) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.ParameterizedType;

public class Main {

    public static Class getGenericsClass(Class cls) throws Exception {
        ParameterizedType superClass = (ParameterizedType) cls.getGenericSuperclass();
        Class target = (Class) superClass.getActualTypeArguments()[0];
        return target;
    }//w  w  w.j a  v a2  s . c  om
}

Related

  1. getGenericParameterClass(Class clazz)
  2. getGenericParameters(Class clazz)
  3. getGenericParameterType(Class clazz, Integer parameterIndex)
  4. getGenericParameterType0(Class cls, Class genericSuper, int paramIndex)
  5. getGenerics(Class classType)
  6. getGenericSuperclass(Class clazz)
  7. getGenericSuperclass(Class cls)
  8. getGenericSuperclassActualTypes(Collection types, Class aClass)
  9. getGenericSuperType(Class clz, int index)