FindBugs Integer与预期的参数类型不兼容?

Chr*_*tti 2 java findbugs object

我正在完成一项任务,我认为我已经找到了问题,但我得到了相同的结果.使用FindBugs应用程序,我能够通过以下代码行看到一个大的:

out.writeObject(accountMap.get(i));
Run Code Online (Sandbox Code Playgroud)

我收到一个错误说:

整数与预期的参数类型String不兼容......

所以我通过将int转换为String来纠正它:

out.writeObject(accountMap.get(Integer.toString(i)));
Run Code Online (Sandbox Code Playgroud)

有了相同的bug结果.我误会了什么吗?

Ian*_* Mc 6

我重新创建了你的问题,Findbugs发现了同样的错误.到现在为止还挺好.

Integer is incompatible with expected argument type String in ...(String[]) [Scariest(1), High confidence]
Run Code Online (Sandbox Code Playgroud)

然后我应用你的更改(Integer.toString(i)),并在再次运行Findbugs时发现,错误被清除(这与你的观察不同).

我怀疑你没有重新运行findbugs?

我用Findbugs版本测试:3.0.1.20150306-5afe4d1

PS:这里有一些关于为什么存在错误的历史(与Map#相关而不使用泛型): 为什么java.util.Map.get(...)不是通用的?