I think, and I emphasize think, that I can help with this generic question, but I apologize in advance if I've misunderstood.
Type erasure is real and irrevocable. Given an object of a generic class, there is absolutely no way to recover the parameters. If you want to carry the information around, you have to use reflection to get hold of the classes that can describe a generic. Tatu Saloranta's JSON libraries include some very clever type descriptors that allow you to fairly easily get a reference to one of these for an arbitrary type. To avoid casts that get compile warnings, it's typical to have APIs like T getFoo(Class<T> clazz, whatever) and return class.cast(returnValue); This gives you return type checking and avoids the warnings. The collections library intentionally avoids this and internally has all those warnings to allow compatibility.