jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes StackOverflowError in hashCode due to recursion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "StackOverflowError in hashCode due to recursion" Watch "StackOverflowError in hashCode due to recursion" New topic
Author

StackOverflowError in hashCode due to recursion

Dave Joyce
Greenhorn

Joined: Jul 30, 2007
Posts: 1

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!
 
 
subject: StackOverflowError in hashCode due to recursion
 
Similar Threads
ID:8 SCJP Question of the day !!!
Sorting through Comparable(Very Urgent)
problem with @FieldResult, mapping does not seem to work
Error setting the expression with value [Ljava.lang.String;@1d05b0a
Incompatible type issue