在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. iOS中如何选择delegate、通知、KVO(以及三者的区别)

    转载自:http://blog.csdn.net/dqjyong/article/details/7685933 在开发IOS应用的时候,我们会经常遇到一个常见的问题:在不过分耦合的前提下,contr ...

  2. Android中对内存和外存的读写

    首先给大家介绍使用文件如何对数据进行存储,Activity提供了openFileOutput()方法可以用于把数据输出到文件中,具体的实现过程与在J2SE环境中保存数据到文件中是一样的. public ...

  3. python 学习笔记11(objgraph)

    33. objgraph objgraph是Python的一个第三方包.安装之前需要安装xdot. 用途 安装 例子

  4. Linux 简介

    转载:http://c.biancheng.net/cpp/html/2726.html Linux简介 严格的来讲,Linux 不算是一个操作系统,只是一个 Linux 系统中的内核,即计算机软件与 ...

  5. 图像卷积、相关以及在MATLAB中的操作

    图像卷积.相关以及在MATLAB中的操作 2016年7月11日 20:34:35, By ChrisZZ 区分卷积和相关 图像处理中常常需要用一个滤波器做空间滤波操作.空间滤波操作有时候也被叫做卷积滤 ...

  6. Redis未授权访问漏洞分析

    catalog . Redis简介 . 漏洞概述 . 漏洞利用方式 . 修复方式 1. Redis简介 Relevant Link: http://www.cnblogs.com/LittleHann ...

  7. grid列的值格式化

    //列格式化 waf.defineCustomeClass("cellformatter.ratioFomatter", cellformatter.defaultFormatte ...

  8. Spring MVC exception - Invoking request method resulted in exception : public static native long java.lang.System.currentTimeMillis()

    最近在线上系统发现下面的异常信息: 2014-10-11 11:14:09 ERROR [org.springframework.web.servlet.mvc.annotation.Annotati ...

  9. STL之lower_bound和upper_bound

    ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一个非递减序列[first, la ...

  10. BZOJ2599 [IOI2011]Race

    传送门 点分治,黄学长的选根方法会T掉,换了这个人的选根方法就可以了. 当然,你也可以选择黄学长的奇淫优化 //BZOJ 2599 //by Cydiater //2016.9.23 #include ...