• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Findbug continues to report the same bugs

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

John
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
John Vorwald
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Cheers,
John
 
reply
    Bookmark Topic Watch Topic
  • New Topic