Assume that I have an annotation that generates a warning. The annotation is on a method.
e.g.
@AnnotationThatGeneratesAWarning
public void doSomething() {
//stuff
}
Can I use @SuppressWarnings
to suppress it? Does @SuppressWarnings
work with warnings generated by annotations, or just on warnings generated by the method itself?
What IDE are you using? What's the code that generates the warning?. A good IDE will generally suggest the String to use in the @SuppressWarnings
, but it's better to first try to fix the warning, if that's not possible and as a last resource use @SuppressWarnings
.
EDIT :
You can tell that @SuppressWarnings
won't work with other annotations looking at its documentation. As you can see:
@Target(value={TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
The targets do not include ANNOTATION_TYPE
, meaning that @SuppressWarnings
can not be applied to other annotations.