This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I am having trouble fixing the bugs that are found.
For example, the following bug was identified
Produces the bug "Pattern: Call to static DateFormat ..."
Replaced the code with
But, I continue to get the message: "Pattern: Call to static DateFormat ..."
Also, I had a class that override equal. I got the message: "Bug: support.tree.NeuralNetConfiguration defines equals and uses Object.hashCode()".
The bug message appeared on the declartion of the equal member.
So, I wrote the hashCode for the class, and now the message appears on the first line of the hashCode member, which has the same line number as the previous location of member equal.
It looks like find bug is reporting previous errors. I'm in Eclipse, and have done project clean/rebuild, and changed the settings on findbug to work harder. But, continue to get message that appear to be from the original source code, and not being updated with the modified source code.
I don't know why FindBugs exactly gives you that first error message. But on the FindBugs website you can look it up in the list of bug descriptions, where you'll find more info on what the message means exactly and how you could solve it.
For the second point: Whenever you override equals(), you should override hashCode() as well. These two methods are used together by hash-based collections such as HashMap and HashSet. If they are not implemented according to the rules described in the API documentation for Object.hashCode, then your class will not work properly when used as a HashMap key or value in a HashSet.
Seems that the problem was that I had turned off automatic build in Eclipse. So, after modifying the code, findbugs was still looking at the build from the original code. Alternatively, I can leave automatic build off, and then have to do a manual build before running findbugs.