java-ObjectName与String FindBug错误不兼容
作者:互联网
对于我的生产代码,类似于以下内容:
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作为字符串,如下所示:http://download.oracle.com/javase/6/docs/api/javax/management/ObjectName.html
这是Findbugs的问题,还是我缺少什么?
解决方法:
public something xyz(String name) {
return getSomething(abc.get(new ObjectName(name)));
}
标签:findbugs,java 来源: https://codeday.me/bug/20191102/1989272.html