abstract class BaseDao<T> {
public BaseDao() {
Type t = getClass().getGenericSuperclass();
ParameterizedType p = (ParameterizedType) t ;
Class<T> c = (Class<T>) p.getActualTypeArguments()[0];
System.out.println("子类通过junity来实例化,会先实例化父类:"+c.getName());
}
}
public class SubDao extends BaseDao<String> {
public SubDao() {
System.out.println("子类构造");
}
@Test
public void test1() {
}
}