Avoiding Java Type Erasure
Is there a way one could avoid type erasure and get access to a type parameter? public class Foo<T extends Enum<?> & Bar> { public Foo() { // access the template class here? // i.e. : baz(T.class); // obviously doesn't work } private void baz(Class<T> qux) { // do stuff like T[] constants = qux.getEnumConstants(); ... } } I need to know about T , and do things with it. Is it possible, and if so, how can it be done without passing in the class in the constructor or anywhere besides the parameter? EDIT: The main purpose of this question is to find out if there is any practical way around type