Community
Participate
Working Groups
Build: I20061031 Say there is an interface that uses a raw type, such as IAdaptable: public Object getAdapter(Class clazz); And say there is a class that implements this interface, and is compiled with Java 5. A warning is generated about the usage of raw type Class. I think classes that implement IAdaptable and declare this method should not be warned about using a raw type, because they are forced to do so by the declaration in the super type. I.e., they are being warned about something they don't have the power to fix. See discussion in bug 149805.
Removing the warning just in signatures of overridden methods may be difficult to explain to the user. E.g. if clazz is assigned to a local variable of raw type Class inside the method body, that would still raise a warning. Same with methods called on the parameter, or assignments to a parameterized version of the type, etc.
Another option is to have an extra checkbox that says "Check overriding and implementing methods", like you do for "Unnecessary declaration of thrown checked exception" and "Parameter is never read"
I wonder if the implementing signature falls out of what the programmer would consider "usage of raw type", since the implementing signature is not something the programmer controls. It either comes from a superclass they control, or a library that they don't. If so something like the following could work, but it sure is tricky to phrase clearly. If not I like John's suggestion, but the check box label would need to make it clear that the body will be checked, and that only the signature will be ignored. Generic Types Usage of raw type [Warning] Method signatures implementing/overriding raw type [Ignore]
Indeed, since this is not allowed: interface Adaptable { public Object getAdapter(Class clazz); } public class X implements Adaptable { @Override public Object getAdapter(Class<?> clazz) { return null; } }
However, you can write instead: interface Adaptable { public Object getAdapter(Class clazz); } public class X implements Adaptable { @Override public Object getAdapter(@SuppressWarnings("unchecked") Class clazz) { return null; } }
Added AnnotationTest#test264 Added MethodVerifyTest#test179
*** This bug has been marked as a duplicate of bug 322817 ***