import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import org.junit.Test;
abstract class BaseDao<T> {
public void getType() {
//Class<E> clazz = (Class<E>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
Type t = getClass().getGenericSuperclass();
ParameterizedType p = (ParameterizedType) t ;
Class<T> c = (Class<T>) p.getActualTypeArguments()[0];
System.out.println(c.getName()); //java.lang.String
}
}
public class SubDao extends BaseDao<String> {
@Test
public void test1() {
getType();
}
}