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
@SuppressWarningswon’t work with other annotations looking at its documentation. As you can see:The targets do not include
ANNOTATION_TYPE, meaning that@SuppressWarningscan not be applied to other annotations.