@SuppressWarnings的使用、作用、用法
在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的使用、作用、用法的更多相关文章
- @suppresswarnings(unchecked)的作用
@suppresswarnings(unchecked)的作用 一般在项目中会出现红色的报错,这个是影响项目运行的,无法启动,会停在那里,而warning警告,黄色的虽然不是会让项目停止,但是却是不规 ...
- JAVA中@SuppressWarnings注解的作用
eclipse中开发JAVA代码时,经常会出现编译告警符号,影响代码可读性,也影响调试的断点符号正常显示,可以使用@SuppressWarnings注解来抑制这些告警符号的再现.1.抑制单个类型的告警 ...
- hadoop-Combiner作用用法
文章来源http://blog.csdn.net/ipolaris/article/details/8723782 reduce的输入每个key所对应的value将是一大串1,但处理的文本很多时,这一 ...
- JAVA 泛型 通配符? extends super限定,实例区分extends super限定的作用用法
java泛型中的关键字 ? 表示通配符类型 <? extends T> 既然是extends,就是表示泛型参数类型的上界,说明参数的类型应该是T或者T的子类. <? super T& ...
- @SuppressWarnings注解用法详解
@SuppressWarnings注解用法详解 今天来谈谈@SuppressWarnings注解的作用. J2SE 提供的最后一个批注是 @SuppressWarnings.该批注的作用是给编译器一条 ...
- @SuppressWarnings注解用法详解(转)
原文连接https://blog.csdn.net/sysware_carol/article/details/52100580 今天来谈谈@SuppressWarnings注解的作用. J2SE 提 ...
- meta的用法
META标签,是HTML语言head区的一个辅助性标签.在几乎所有的page里,我们都可以看 到类似下面这段html代码: -------------------------------------- ...
- Android RxJava 2 的用法 just 、from、map、subscribe、flatmap、Flowable、Function、Consumer ...【转】
先简单说说RxJava的用途与价值 原文出处:Android RxJava 2 的用法 用途: 异步 (也就是开线程跳转) 价值: 面对复杂的逻辑,它依然 简洁 ,代码 易读 RxJava2 与 Rx ...
- Java Annotation认知(包括框架图、详细介绍、示例说明)
摘要 Java Annotation是JDK5.0引入的一种注释机制. 网上很多关于Java Annotation的文章,看得人眼花缭乱.Java Annotation本来很简单的,结果说的人没说清楚 ...
- Java Annotation认知(包括框架图、详细介绍、示例说明)(转)
本文转自:http://www.cnblogs.com/skywang12345/p/3344137.html 网上很多关于Java Annotation的文章,看得人眼花缭乱.Java Annota ...
随机推荐
- NPOI简介
NPOI 是 POI 项目的 .NET 版本.POI是一个开源的Java读写Excel.WORD等微软OLE2组件文档的项目. (一)传统操作Excel遇到的问题: 1.如果是.NET,需要在服务器端 ...
- Spark 学习笔记1 (常见术语 )
本来没打算学Spark 的,不过时机很逗. 最膜拜的大神做spark分享,还是其中最好玩的notebook.这不就是另外一个 HUE吗,但感觉更好玩. 刚好新的Spark 2.x 要问世了,大神在组织 ...
- BZOJ 1853: [Scoi2010]幸运数字
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 2117 Solved: 779[Submit][Status] ...
- ng-学习笔记1
1.ng-model绑定输入域的数据到控制器的属性.修改输入域的值,属性的值也将修改(双向绑定) 2.ng-repeat可用于创建表格,使用 <td>{{ $index + 1 }}< ...
- linux软件包的安装和卸载
这里分两种情况讨论:二进制包和源代码包. 一.linux二进制分发软件包的安装和卸载 Linux软件的二进制分发是指事先已编译好二进制形式的软件包的发布形式,其长处是安装使用容易,缺点则是缺乏灵活性, ...
- Leetcode 347. Top K Frequent Elements
Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2 ...
- 【BZOJ-3262】陌上花开 CDQ分治(3维偏序)
3262: 陌上花开 Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 1439 Solved: 648[Submit][Status][Discuss ...
- 【poj1020】 Anniversary Cake
http://poj.org/problem?id=1020 (题目链接) 题意 有一个S*S的大蛋糕,还有许多正方形的小蛋糕,问能否将大蛋糕完整的分成所有的小蛋糕,不能有剩余. Solution 像 ...
- Oracle 11g新特性
文章转自网络 Oracle 11g于2007年7月11日美国东部时间11时(北京时间11日22时)正式发布,11g是甲骨文公司30年来发布的最重要的数据库版本,根据用户的需求实现了信息生命周期管理(I ...
- 帝国cms搜索表单用法
还有一些没有测试,用到了再补充. <form action="[!--news.url--]e/search/index.php" method="post&quo ...