Since the introduction of generic type parameters (or type arguments) in Java, writing the following line in Eclipse IDE will show a yellow squiggly line on the type
The warning shown on a mouseover is the following, with the two options (among others):
Classis a raw type. References to the generic type
Class<T>should be parameterized.
- Add type arguments to ‘
rawtypes‘ to ‘
The first option produces this code:
The second one produces this:
@SuppressWarnings("rawtypes") Class myClass;
Both of the above options are equally adequate in taking care of the warning.
Assuming neither we nor Eclipse can infer generic type arguments*; what is the better approach to take, in what situations, and why?
* (despite having the option to try to do so)