Java: Instanceof and Generics
The error message says it all. At runtime, the type is gone, there is no way to check for it. You could catch it by making a factory for your object like this: public static <T> MyObject<T> createMyObject(Class<T> type) { return new MyObject<T>(type); } And then in the object’s constructor store that type, so variable … Read more