File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Findbug continues to report the same bugs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Findbug continues to report the same bugs" Watch "Findbug continues to report the same bugs" New topic

Findbug continues to report the same bugs

John Vorwald
Ranch Hand

Joined: Sep 26, 2010
Posts: 139
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.

Any suggestions / recommendations?

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

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.

See also item 9 in Effective Java.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
John Vorwald
Ranch Hand

Joined: Sep 26, 2010
Posts: 139
Thanks for the comments.

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.

I agree. Here's the link:
subject: Findbug continues to report the same bugs
It's not a secret anymore!