Class<T>
is a bad idea. It's a two-way lie. It cannot represent arbitrary T - often code that needs to take in a typeref
does not know if the type ref you want to take in is generics-free, and
Class<T>
cannot represent any type that contains generics. But, it's even worse -
j.l.Class
can represent primitives;
int.class
is a thing. But generics
cannot. So, it's just a dumb fucking idea, and
Class<T>
as a parameter is pretty much an automatic veto in code review from me. There are always better answers. In rare cases, it's supertypetokens like here. In most others, factories. —
rzwitserloot 5 secs ago