I have a generics class, Foo. In a method of Foo, I want to get the class instance of type T, but I just can\'t call T.
Foo
T
T.
public T yourMethodSignature(Class type) { // get some object and check the type match the given type Object result = ... if (type.isAssignableFrom(result.getClass())) { return (T)result; } else { // handle the error } }