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

@SuppressWarnings(“XXXX”) 来解决

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

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

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

Update #1All 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

JavaSE: SuppressWarnings[转]的更多相关文章

  1. 回顾javase点滴

    数据类型 8种基本数据类型和引用类型 数据类型 占用位数 存储方式 最小值 最大值 默认值 byte 8 1+7 -128(-2^7) 127(2^7-1) 0 short 16 1+15 -3276 ...

  2. JavaSE知识概述集

    一.HelloWord(文档启动Java) /* 使用命令行的方式执行的时候,cmd的默认编码格式是GBK 因此在输入中文的时候需要设置文件的编码格式位ANSI,不会出现乱码错误 注意: 0.先用ja ...

  3. 枚举和注解@override、@Deprecated、@SuppressWarnings

    一.枚举 简介: 1)枚举对应英文(enumeration,简写 enum) 2)枚举是一组常量的集合. 3)可以这里理解:枚举属于一种特殊的类,里面只包含一组有限的特定的对象. 实现方式: 1.自定 ...

  4. 用大白话聊聊JavaSE -- 如何理解Java Bean(一)

    首先,在开始本章之前,先说一个总的概念:所谓的Java Bean,就是一个java类,编译后成为了一个后缀名是 .class的文件.这就是Java Bean,很多初学者,包括当年的我自己,总是被这些专 ...

  5. javaSE基础07

    javaSE基础07 一.static静态修饰符 用了static修饰的变量就会变成共享的属性,只会初始化一次,在内存中只存在一个,并且每个对象都可以访问,存放在方法区(数据共享区) 1.1 stat ...

  6. javaSE基础06

    javaSE基础06 一.匿名对象 没有名字的对象,叫做匿名对象. 1.2匿名对象的使用注意点: 1.我们一般不会用匿名对象给属性赋值的,无法获取属性值(现阶段只能设置和拿到一个属性值.只能调用一次方 ...

  7. javaSE基础05

    javaSE基础05:面向对象 一.数组 数组的内存管理 : 一块连续的空间来存储元素. Int [ ] arr = new int[ ]; 创建一个int类型的数组,arr只是一个变量,只是数组的一 ...

  8. javaSE基础04

    javaSE基础04 一.三木运算符 <表达式1> ? <表达式2> : <表达式3> "?"运算符的含义是: 先求表达式1的值, 如果为真, ...

  9. javaSE基础03

    javaSE基础03 生活中常见的进制:十进制(0-9).星期(七进制(0-6)).时间(十二进制(0-11)).二十四进制(0-23) 进制之间的转换: 十进制转为二进制: 将十进制除以2,直到商为 ...

随机推荐

  1. Linux中文件MD5校验

    md5sum命令用于生成文件的md5数字摘要,并可以验证文件内容是否发生了改变,间接地还可以检验两个文件内容是否完全相同.因为md5sum是读取文件内容来计算校验码的,因此只能验证文件内容,而无法验证 ...

  2. C 程序与 C++ 程序之间的相互调用

    因为 C 编译器编译函数时不带参数的类型信息,只包含函数的符号名字.如 void foo( int x ) , C 编译器会将此函数编译成类似 _foo 的符号,C 链接器只要找到了调用函数的符号,就 ...

  3. 创作型---原型模式(C# ICloneable接口的实现)

    在软件系统中,当创建一个类的实例的过程很昂贵或很复杂,并且我们需要创建多个这样类的实例时,可以通过对原来对象拷贝一份来完成创建,这样在内存中不需要创建多个相同的类实例,从而减少内存的消耗和达到类实例的 ...

  4. python之isinstance内建函数

    语句: isinstance(object,type) 作用: 来判断一个对象是否是一个已知的类型. 解释: 其第一个参数(object)为对象,第二个参数(type)为类型名(int...)或类型名 ...

  5. JavaScript 笔记(一)

    Number 1.2345e3=1.2345*1000 NaN//not a num 无法计算结果 Infinity //无限大 数组 var arr=[1,2,'hello'] 下标从0开始 对象 ...

  6. canvas-8searchLight2.html

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. js 金额处理加小数点后两位

    function toDecimal2(x) { var f = parseFloat(x); if (isNaN(f)) { return false; } var f = Math.round(x ...

  8. win10电脑怎么录制视频 电脑录制视频软件

    win10电脑怎么录制视频?相信不少网友正在面临这个疑惑.现如今是网络信息科技时代,快速传播信息的途径和方式有很多种.其中,通过录制电脑视频,可以制作视频教程.游戏解说,还可以录制在线视频存储影视资源 ...

  9. Landsat数据下载方法小结

    本文转载自:http://malagis.com/landsat-data-download.html 本文介绍下载Landsat数据的方法. Landsat(美国陆地卫星)是遥感应用中常用的卫星数据 ...

  10. 开发Spring过程中几个常见异常(二):Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'a' define

    本异常是小编在运行自己另外一篇博文中的例子时遇到的.(附博文:http://www.cnblogs.com/dudududu/p/8482487.html) 完整异常信息: 警告: Exception ...