Here you can find the source of getGenericClass(Object o)
public static Class getGenericClass(Object o)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.ParameterizedType; public class Main { public static Class getGenericClass(Object o) { ParameterizedType parameterizedType = (ParameterizedType) o.getClass().getGenericSuperclass(); return (Class) parameterizedType.getActualTypeArguments()[0]; }/*from ww w. j a v a 2 s . c om*/ }