具体可在eclipse中当代码有黄色下划线时通过Ctrl+1来观察需要加上什么参数的suppresswarnings以及不同参数的区别
通过 @SuppressWarnings (压制注解)的源码可知,其注解目标为类、字段、函数、函数入参、构造函数和函数的局部变量。 通常情况下建议注解应声明在最接近警告发生的位置。
@SuppressWarnings("unchecked") @SuppressWarnings(value={"unchecked", "rawtypes"})
deprecation 使用了不赞成使用的类或方法时的警告 unchecked 执行了未检查的转换时的警告,例如当使用集合时没有用泛型 (Generics) 来指定集合保存的类型。如:List<String> list = doSometing(); doSometing返回的是List<Object>,但是你知道是List<String> path 在类路径、源文件路径等中有不存在的路径时的警告。 serial 当在可序列化的类上缺少 serialVersionUID 定义时的警告。 finally 任何 finally 子句不能正常完成时的警告。
这里输入引用文本这里是列表文本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(过时的annotation)
deprecation to suppress warnings relative to deprecation(过时)
fallthrough to suppress warnings relative to missing breaks in switch statements(switch无break)
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)(枚举时不完整的switch)
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(无序列化id)
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(未使用)