Suppress unchecked warnings on method calls in Java
Let’s say you have a method call like this:
beanWrapper.getPropertyValue</a> returns an Object. If you have the “Unchecked generic type operation” compiler setting set to warning, you will get the following warning:
If you are using Eclipse, it will give you a quick fix to add a
@SuppressWarnings(value = "unchecked") annotation, but only give you the option to add it to the current method.
(the current method in this case is
But we may not want to suppress warnings for the entire method. We can just put the annotation on the method call itself: