Supported Values for @SuppressWarnings(转)

Update July 2011This list has been reviewed and
made current with the most recent Eclipse 3.7 release.

If you are a Java developer and use the new @SuppressWarnings annotation in
your code from time-to-time to suppress compiler warnings you, like me, have
wondered probably about a million times already just exactly
what
 are the supported valuesthat can be used with this
annotation.

The reason the list isn’t easy to find is because it’s compiler specific,
which means Sun may have a different set of supported values than say IBM, GCJ
or Apache Harmony.

Fortunately for us, the Eclipse folks have
documented the values they support
 (as of Eclipse
3.7), here they are for reference:

  • all to suppress all warnings

  • boxing to suppress warnings relative to boxing/unboxing
    operations

  • cast to suppress warnings relative to cast
    operations

  • dep-ann to suppress warnings relative to deprecated
    annotation

  • deprecation to suppress warnings relative to
    deprecation

  • fallthrough to suppress warnings relative to missing
    breaks in switch statements

  • finally to suppress warnings relative to finally block
    that don’t return

  • hiding to suppress warnings relative to locals that hide
    variable

  • incomplete-switch to suppress warnings relative to
    missing entries in a switch statement (enum case)

  • nls to suppress warnings relative to non-nls string
    literals

  • null to suppress warnings relative to null analysis

  • rawtypes to suppress warnings relative to un-specific
    types when using generics on class params

  • restriction to suppress warnings relative to usage of
    discouraged or forbidden references

  • serial to suppress warnings relative to missing
    serialVersionUID field for a serializable class

  • static-access to suppress warnings relative to incorrect
    static access

  • synthetic-access to suppress warnings relative to
    unoptimized access from inner classes

  • unchecked to suppress warnings relative to unchecked
    operations

  • unqualified-field-access to suppress warnings relative
    to field access unqualified

  • unused to suppress warnings relative to unused code

TIP: For the folks that haven’t used @SuppressWarnings
before, the syntax looks like this:

@SuppressWarnings(“unused”)

and can be placed above almost any piece of code that is causing a compiler
warning to popup for your class.

Update #1: Thanks to Pierre for the addition of the
‘rawtypes’ argument and description.

时间: 2024-10-05 06:57:46

Supported Values for @SuppressWarnings(转)的相关文章

Supported Values for @SuppressWarnings

Update July 2011: This list has been reviewed and made current with the most recent Eclipse 3.7 release. If you are a Java developer and use the new @SuppressWarnings annotation in your code from time-to-time to suppress compiler warnings you, like m

(转)@SuppressWarnings的使用、作用、用法

在java编译过程中会出现很多警告,有很多是安全的,但是每次编译有很多警告影响我们对error的过滤和修改,我们可以在代码中加上 @SuppressWarnings(“XXXX”) 来解决 例如:@SuppressWarnings("deprecation")表示不显示使用了不赞成使用的类或方法时的警告 具体的XXXX的意义可以参考博文 http://www.thebuzzmedia.com/supported-values-for-suppresswarnings/ Update #

JavaSE: SuppressWarnings[转]

在java编译过程中会出现很多警告,有很多是安全的,但是每次编译有很多警告影响我们对error的过滤和修改,我们可以在代码中加上 @SuppressWarnings(“XXXX”) 来解决 例如:@SuppressWarnings("deprecation")表示不显示使用了不赞成使用的类或方法时的警告 具体的XXXX的意义可以参考博文 http://www.thebuzzmedia.com/supported-values-for-suppresswarnings/ Update #

dbrd 8.4.6 源代码编译安装

---------------------------- 0.系统环境 ---------------------------- db01 192.168.50.10 /dev/sdb1 主节点 db02 192.168.50.20 /dev/sdb1 备节点 # grep -v "#" /etc/hosts 192.168.50.10 db01 db01.mysql.com 192.168.50.20 db02 db02.mysql.com #一块新硬盘 ll /dev/sd* ll

TextKit 的使用----

TextKit是在iOS7中新出的,实现了对CoreText的封装,使用起来更加方便. 虽然是新出的,但也不代表立马就能上手-_-!!,TextKit可以实现图文混排效果,很好用. 1. 使用TextKit加载基本的文本 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 - (void)viewDidLoad {     [super viewDidLoad];     // 装载内容的容器     NS

Postman-CI集成Jenkins

Postman-简单使用 Postman-进阶使用 Postman-CI集成Jenkins Newman 官方说明:Postman's command-line companion lets you do amazing things! With Newman, you can integrate Postman collections with your build system. Or you can run automated tests for your API through a cr

关于bootstrap-datetimepicker 插件的配置参数详解

本人在网上查找的,  觉得还不错,就抄过来了... 有错误大家一起讨论,谢谢... 原地址是:http://www.bootcss.com/p/bootstrap-datetimepicker/ 项目  此项目是bootstrap-datetimepicker 项目 的一个分支,原项目不支持 Time 选择.其它部分也进行了改进.增强,例如load 过程增加了对 ISO-8601 日期格式的支持.文档是拷贝/粘贴字原项目的文档,并且加入了更多细节说明. 别犹豫了,下载下来试试吧 ! 下载 ZIP

Linux多线程实践(3) --线程属性

初始化/销毁线程属性 int pthread_attr_init(pthread_attr_t *attr); int pthread_attr_destroy(pthread_attr_t *attr); 线程分离属性 int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); int pthread_attr_setdetachstate(pthread_attr_t *attr, int de

使用ndk standalone工具链来编译某个平台下的库

地址: http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html It is now possible to use the toolchain provided with the Android NDK as a standalone compiler. This can be useful if you already have your own build system, and only need to ability to i