Detecting the generic type in runtime

Assuming we have a class:


public abstract class GenericDAOImpl


Now what if we need to get the "Class" object identifying the generic type's class type in run time ?


Class entityClass = (Class)((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];


Kindly share if there are other ways.

Comments

Popular posts from this blog

Hosting Apache Tapestry5.1 on GAE (Google App Engine)

Testing SOAP services using pingdom

How to undo Git commits ?