• Post Reply Bookmark Topic Watch Topic
  • New Topic

StackOverflowError in hashCode due to recursion  RSS feed

Dave Joyce
Posts: 1
Mac OS X Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Well, I know what my problem is, but I don't know how to solve it. Here's the scenario:

I have an abstract superclass ContactsEntry, which has subclasses Group and Person. As a note, I'm using the HashCodeUtil and EqualsUtil classes based on Josh Bloch's discussions from Effective Java, which are found at Implementing hashCode and Implementing equals, respectively.

These domain model classes are structured to provide a nodetree-like structure, but I'm getting a StackOverflowError between Group and Person classes, due to the dreaded infinite recursion loop blowout in the hashCode() method.

Finally, here's the obvious stack trace:

How do I break out of the recursive loop? Thanks!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!