1

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.

Community
  • 1
  • 1
Vishrant
  • 15,456
  • 11
  • 71
  • 120

1 Answers1

2

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.

Adi
  • 2,364
  • 1
  • 17
  • 23