对于我的生产代码,类似于以下内容:
public something xyz(String name) {
return getSomething(abc.get(name));
}
如果方法“get”期望将javax.management.ObjectName传递给它,我将从Findbugs工具获得以下高优先级警告:
Bug: String is incompatible with expected argument type javax.management.ObjectName
Pattern id: GC_UNRELATED_TYPES, type: GC, category: CORRECTNESS
但是,根据javax API文档,我看到可以将ObjectName作为String,如下所示:http://download.oracle.com/javase/6/docs/api/javax/management/ObjectName.html
这是Findbugs的问题还是我错过了什么?
答案 0 :(得分:4)
public something xyz(String name) {
return getSomething(abc.get(new ObjectName(name)));
}