Java uses type erasure to handle generics. This means that all information about generics is only checked at compile time, and the resulting bytecode has no reference at all to the fact that generics were used.
List<String> stringList = new ArrayList<String>();
stringList.add("foo");
String s = stringList.get(0);
will (after doing compile time checks on the generic parameters) will basically compile to the same thing as
List stringList = new ArrayList();
stringList.add("foo");
String s = (String)(stringList.get(0));
What this means is that you can't do any runtime checks on a generic parameter directly, like what you're trying to do.
If you have a specific object of a genericized type, you can use the instanceof
operator to determine if that object is an instance of a specific class, but you can't do anything on the actual generic parameter itself, because that gets type-erased at runtime.