I have the following class:
public abstract class MyClass<T extends Object> {
protected T createNewFromData(Reader reader){
GSON.fromJSON(reader,T.class); // T.class isn't allowed :(
}
}
How do I pass a Class<T> instance into there? Is there some wierd and wacky work around?
Is there a way to get a Class<T> reference other than from a pre-instantiated Object of type T? It won’t let me do this either:
T t = new T();
Class<T> klass = t.class;
Attempt #2
Interestingly, if I remove the “extends JSONOBjBase” from the class definition, I simply get an unchecked cast WARNING (no error). Is there another way to write how the cast is done?

Or you can send the Class as a constructor argument and use that object instead of trying to get T.class.