Return to Snippet

Revision: 199
at July 4, 2006 08:43 by leazen


Initial Code
class A<T> {

  Class<T> specializedClass;

  public A() {
    this.specializedClass = (Class<T>) ((ParameterizedType) this.getClass()
                .getGenericSuperclass()).getActualTypeArguments()[0];
  }

}

Initial URL

                                

Initial Description
This code will only work for immediate specialization not something like class B extends A.

Initial Title
Get parametrized type in runtime

Initial Tags

                                

Initial Language
Java