在java编译过程中会出现很多警告,有很多是安全的,但是每次编译有很多警告影响我们对error的过滤和修改,我们可以在代码中加上

@SuppressWarnings(“XXXX”) 来解决

例如:@SuppressWarnings("deprecation")表示不显示使用了不赞成使用的类或方法时的警告

具体的XXXX的意义可以参考博文

http://www.thebuzzmedia.com/supported-values-for-suppresswarnings/

Update #1: All these annotations are still valid
in Eclipse 3.4 and 3.5, there have been no new SuppressWarning
arguments added in those versions of the JDT compiler.

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 alreadyjust exactly what are the supported
values that 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.3), 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
    • 来自:http://blog.csdn.net/mddy2001/article/details/8291484
    • 欧chuquan 见解:以前看《Effective Java 中文版(第二版》的时候作者很提倡解决一切的警告,有时候就是用@SuppressWarnings解决一些无需解决的警告。

@SuppressWarnings的使用、作用、用法的更多相关文章

  1. @suppresswarnings(unchecked)的作用

    @suppresswarnings(unchecked)的作用 一般在项目中会出现红色的报错,这个是影响项目运行的,无法启动,会停在那里,而warning警告,黄色的虽然不是会让项目停止,但是却是不规 ...

  2. JAVA中@SuppressWarnings注解的作用

    eclipse中开发JAVA代码时,经常会出现编译告警符号,影响代码可读性,也影响调试的断点符号正常显示,可以使用@SuppressWarnings注解来抑制这些告警符号的再现.1.抑制单个类型的告警 ...

  3. hadoop-Combiner作用用法

    文章来源http://blog.csdn.net/ipolaris/article/details/8723782 reduce的输入每个key所对应的value将是一大串1,但处理的文本很多时,这一 ...

  4. JAVA 泛型 通配符? extends super限定,实例区分extends super限定的作用用法

    java泛型中的关键字 ? 表示通配符类型 <? extends T> 既然是extends,就是表示泛型参数类型的上界,说明参数的类型应该是T或者T的子类. <? super T& ...

  5. @SuppressWarnings注解用法详解

    @SuppressWarnings注解用法详解 今天来谈谈@SuppressWarnings注解的作用. J2SE 提供的最后一个批注是 @SuppressWarnings.该批注的作用是给编译器一条 ...

  6. @SuppressWarnings注解用法详解(转)

    原文连接https://blog.csdn.net/sysware_carol/article/details/52100580 今天来谈谈@SuppressWarnings注解的作用. J2SE 提 ...

  7. meta的用法

    META标签,是HTML语言head区的一个辅助性标签.在几乎所有的page里,我们都可以看 到类似下面这段html代码: -------------------------------------- ...

  8. Android RxJava 2 的用法 just 、from、map、subscribe、flatmap、Flowable、Function、Consumer ...【转】

    先简单说说RxJava的用途与价值 原文出处:Android RxJava 2 的用法 用途: 异步 (也就是开线程跳转) 价值: 面对复杂的逻辑,它依然 简洁 ,代码 易读 RxJava2 与 Rx ...

  9. Java Annotation认知(包括框架图、详细介绍、示例说明)

    摘要 Java Annotation是JDK5.0引入的一种注释机制. 网上很多关于Java Annotation的文章,看得人眼花缭乱.Java Annotation本来很简单的,结果说的人没说清楚 ...

  10. Java Annotation认知(包括框架图、详细介绍、示例说明)(转)

    本文转自:http://www.cnblogs.com/skywang12345/p/3344137.html 网上很多关于Java Annotation的文章,看得人眼花缭乱.Java Annota ...

随机推荐

  1. Cocoa pod的使用注意点

    一.CocoaPods是什么? CocoaPods是一个负责管理iOS项目中第三方开源库的工具.CocoaPods的项目源码在Github上管理.该项目开始于2011年8月12日,在这两年多的时间里, ...

  2. pycharm使用错误排查

    1.pip安装扩展包报错 creating build/temp.linux-x86_64-3.4 x86_64-linux-gnu- -Wformat -Werror=format-security ...

  3. springmvc使用RSA算法加密表单

    今天被吐槽在客户端用js对密码进行md5加密其实也不见得安全.这种做法其实不见得有什么作用,学过计算机网络都知道,在网上抓一个包是很简单的事,就算别人抓包抓不到你原始密码,用这个md5后的密码一样可以 ...

  4. ubuntu apt-get update失败 解决方法

    ubuntu apt-get update失败 1.出现错误:E:Could not get lock /var/lib/apt/lists/lock - open (11: Resource tem ...

  5. BZOJ3295 [Cqoi2011]动态逆序对

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000作者博客:http://www.cnblogs.com/ljh2000-jump/转 ...

  6. Birthday-24

    2013 LEXUS花样滑冰 和母亲在一起,生日快乐!

  7. C#做窗体皮肤

    网上有很好的皮肤控件 SkinEnigne可供使用: 具体步骤: 添加控件SkinEngine. 1.右键“工具箱”.“添加选项卡”,取名“皮肤”. 2.右键“皮肤”,“选择项”弹出对话框. 3.点击 ...

  8. DirectX的引用找不到问题

    今天要用C#开发(vs2010下)DirectSound应用,按照网上说得在: 但我系统里怎么也找不到,我确定安装了DirectX9.0SDK ,因为在C++里做的开发都好好的. 最后看到Dircet ...

  9. CSS基础知识真难啊-position-relative-absolute

    http://blog.csdn.net/libertea/article/details/11662661 -----------position:relative:生成相对定位的元素,相对于其正常 ...

  10. django入门记录 2

    1. 创建一个app, python manage.py startapp  appname 2. 设计model,在appname/目录下编辑好model 3. 检测model的修改,python ...