I have a generic method, how could I get the class of T?
class MyClass
{
static <T> void foo(T t)
{
// how to get T.class
}
}
t.getClass() gets the most derived class, but T could be a super class so it does not work in case of MyClass.<Collection>foo(new ArrayList()).