• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

StackOverflowError in hashCode due to recursion

Posts: 1
Mac OS X Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic