Java中的异常压制名

名称字符串 压制的警告 用法示例
all 所有警告 @SuppressWarnings("all")
boxing 装箱/拆箱 @SuppressWarnings("boxing")
unused 代码未使用,例如方法未被使用 @SuppressWarnings("unused")
cast 类型转换 @SuppressWarnings("cast")
deprecation 使用了弃用的类或方法 @SuppressWarnings("deprecation")
restriction 使用了不鼓励或禁止的引用 @SuppressWarnings("restriction")
dep-ann 使用了弃用的注解 @SuppressWarnings("dep-ann")
fallthrough switch语句中缺少break语句 @SuppressWarnings("fallthrough")
finally finally块中没有return @SuppressWarnings("finally")
hiding 局部变量隐藏外部变量 @SuppressWarnings("hiding")
incomplete-switch 使用枚举的switch语句中缺少枚举case @SuppressWarnings("incomplete-switch")
nls 非nls字符串 @SuppressWarnings("nls")
null 空引用分析相关的警告 @SuppressWarnings("null")
serial 缺少serialVersionUID字段,此字段通常出现在Serializable类中 @SuppressWarnings("serial")
static-access 访问静态变量方式不正确 @SuppressWarnings("static-access")
synthetic-access 内部类中未优化的访问 @SuppressWarnings("synthetic-access")
unchecked 类型未检查 @SuppressWarnings("unchecked")
unqualified-field-access 非限定字段访问 @SuppressWarnings("unqualified-field-access")
javadoc Javadoc相关 @SuppressWarnings("javadoc")
rawtypes 使用原始类型相关的警告 @SuppressWarnings("rawtypes")
resource 使用Closeable类型的资源相关 @SuppressWarnings("resource")
super 没有超类调用的情况下重写方法相关的警告 @SuppressWarnings("super")
sync-override 在重写synchronized方法时,缺少synchronized而发出的警告 @SuppressWarnings("sync-override")

参考链接

posted @ 2023-01-05 16:08  Freelancy  阅读(47)  评论(0编辑  收藏  举报