This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: StackOverflowError in hashCode due to recursion
 
Similar Threads
Error setting the expression with value [Ljava.lang.String;@1d05b0a
Incompatible type issue
ID:8 SCJP Question of the day !!!
Sorting through Comparable(Very Urgent)
problem with @FieldResult, mapping does not seem to work