Is it possible to suppress this kind of warning?
Note: I am not looking for suppressing all warnings(like this @SuppressWarnings("all")
), but only the mentioned type.
Is it possible to suppress this kind of warning?
Note: I am not looking for suppressing all warnings(like this @SuppressWarnings("all")
), but only the mentioned type.
For Intellij, put this annotation on the class that has the warnings
@SuppressWarnings("SynchronizeOnNonFinalField")
This lead me to the tag to use for suppression and trial and error lead me to put it on the class instead of on the field or synchronized statement. :-P
If you're using IntelliJ, it looks like it's @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
. Otherwise it depends. You might find the answer on the list here: What is the list of valid @SuppressWarnings warning names in Java?
Note that the warning is usually correct. In most cases you should just use a final
field.
This would help you,
All values are permitted (unrecognized ones are ignored). The list of recognized ones is compiler specific.
'unchecked' and 'deprecation' are required by the Java Language Specification, and so should be valid with all compilers. For Sun's compiler, running 'javac -X' gives a list of all values recognized by that version. For 1.5.0_17, the list appears to be:
all deprecation unchecked fallthrough path serial finally
Please refer this, same has discussed here What is the list of valid @SuppressWarnings warning names in Java?