解析 @SuppressWarnings的各种参数

转载 2011年01月02日 11:29:00

转: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 already just 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

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

@SuppressWarnings注解用法详解

@SuppressWarnings注解用法详解

@SuppressWarnings的使用、作用、用法

在Java编译过程中会出现很多警告,有很多是安全的,但是每次编译有很多警告影响我们对error的过滤和修改,我们可以在代码中加上 @SuppressWarnings(“XXXX”) 来解决 例如:@S...

@SuppressWarnings的使用、作用、用法

在java编译过程中会出现很多警告,有很多是安全的,但是每次编译有很多警告影响我们对error的过滤和修改,我们可以在代码中加上 @SuppressWarnings(“XXXX”) 来解决 例如:...
  • mddy2001
  • mddy2001
  • 2012年12月13日 16:45
  • 98629

@SuppressWarnings注解

@SuppressWarnings注解     简介:java.lang.SuppressWarnings是J2SE5.0中标准的Annotation之一。可以标注在类、字段...
  • euyy1029
  • euyy1029
  • 2016年09月12日 11:04
  • 21978

使用 @SuppressWarnings 来排除警告(@SuppressWarning を使用しての警告の排除)

从 Java 5.0 开始,可以使用 java.lang.SuppressWarning 注释来禁用与一部分编译单元相关的编译警告。 Since Java 5.0, you can disable c...

部分域名无法正常弹出portal问题解析

1. 问题现象前几天线上设备出现奇怪的现象,部分终端使用UC浏览器访问部分网站无法弹出portal或弹出portal比较慢,但是其他大部分终端访问可以正常弹出portal,真是莫名其妙,到底是怎么回事...

tomcat配置多域名站点启动时项目重复加载多次

这两天熊哥在配置tomcat多站点的时候遇到一个问题,目前有两个java web项目,要求放在一个tomcat下并通过二级域名问。所以我就在server.xml增加了多个host的配置。但是配置成功后...

suppressWarnings注解参数介绍

  • 2012年07月03日 17:54
  • 431B
  • 下载

@SuppressWarnings注解用法详解

@SuppressWarnings注解用法详解 今天来谈谈@SuppressWarnings注解的作用。 J2SE 提供的最后一个批注是 @SuppressWarnings。该批注的作用是...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:解析 @SuppressWarnings的各种参数
举报原因:
原因补充:

(最多只允许输入30个字)