

| J2SE 5 选项 | 警告类型 |
|---|---|
| Unchecked generic type operation | 编译器每当遇到未经检查的泛型类型操作,就将发出一个错误或者警告。这种操作包括诸如 List 或 ArrayList 等类型上的操作,但没有指定类型。每当您使用一个保存有对象的旧式 Collection 类时就会产生一个警告。 |
| Generic type parameter declared with a final type bound | 编译器每当遇到一个涉及 final 类型的类型绑定时,就会发出一个错误或者警告。请看这个示例方法签名: public int doIt(List<? extends String> list) 因为 String 是 final 类型,参数不能扩展 String,所以这样写比较有效: public int doIt(List<String> list) |
| Inexact type match for vararg arguments | 当编译器不能从 varargs 参数确定开发人员的意图时,它将生成一个警告。有一些与数组相关的 varargs 是不明确的。 |
| Boxing and unboxing conversions | 对自动装箱操作发出警告(装箱操作可能影响性能),并且不再对类型包装对象做对象身份的假设。这是一个默认状态下被忽略的小警告。 |
| Missing @Override annotation | 应该为任何重写的方法包含 @Override 注释。缺少这个注释可能表示开发人员没有意识到该方法被重写。 |
| Missing @Deprecated annotation | 由于缺少 @Deprecated 标志而产生的警告。 |
| Annotation is used as super interface | 您不能把 Deprecated 类作为超级接口。例如,不推荐这种写法: public interface BadForm extends Deprecated { } 。 |
| Not all enum constants covered on switch | switch 语句缺少枚举项意味着您可能遗漏一些枚举选项。 |
| Unhandled warning tokens in @SuppressWarnings | Java 5 允许您添加注释以抑制编译器警告。如果您拼写错了一个警告或者使用了一个并不存在的警告,这个标志将发出一个警告。 |
| Enable @SuppressWarnings annotations | 打开程序地(用代码)抑制您不关心的警告的能力。 |