Reputation: 16698
I was reading this question, where @SuppressWarnings
annotation is used on class level.
Suppose I have multiple classes in my application, so is there a way that I can use @SuppressWarnings
on application level? As applying @SuppressWarnings
on every class is redundant for me.
Upvotes: 1
Views: 683
Reputation: 2394
this is what javadoc says for @SupressWarnings
@Target(value={TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
@Retention(value=SOURCE)
public @interface SuppressWarnings
@Target
clearly mentions places where @SupressWarnings can be applied. So you can not apply at application level. Even doc go ahead and says
As a matter of style, programmers should always use this annotation on the most deeply nested element where it is effective. If you want to suppress a warning in a particular method, you should annotate that method rather than its class.
So its discouraged to do at parent level where it is not applicable.
Upvotes: 2