Re: StackOverflowError on HashMap.hashCode() due to self reference

2015-07-20 Thread Florian Weimer
On 07/17/2015 09:25 PM, Louis Wasserman wrote: > The Javadoc of Map already specifies: > >> > Note: great care must be exercised if mutable objects are used as map > keys. The behavior of a map is not specified if the value of an object is > changed in a manner that affects equals comparisons whil

Re: StackOverflowError on HashMap.hashCode() due to self reference

2015-07-17 Thread Krystal Mok
Hi Louis, hanks! I thought I had seen it somewhere but I couldn't recall where. That's exactly what I need to answer the guys who asked me for a doc reference. Thanks, Kris On Friday, July 17, 2015, Louis Wasserman wrote: > The Javadoc of Map already specifies: > > > Note: great care must be e

StackOverflowError on HashMap.hashCode() due to self reference

2015-07-17 Thread Krystal Mok
Hi Vitaly, I can buy that argument. It wasn't hard for me to recognize it when I saw it in real world. But apparently whoever asked me about it couldn't wrap his head around it to understand why... Maybe it's a case for a Pitfalls book instead of for JavaDocs. Thanks, Kris On Friday, July 17,

Re: StackOverflowError on HashMap.hashCode() due to self reference

2015-07-17 Thread Vitaly Davidovich
IMHO, this doesn't warrant any special wording -- if someone hits this, I think it's fairly evident what the issue is. You can get the same problem with adding an ArrayList to itself and calling hashCode(). On Fri, Jul 17, 2015 at 2:45 PM, Krystal Mok wrote: > Hi everyone, > > I'm sure somebody

StackOverflowError on HashMap.hashCode() due to self reference

2015-07-17 Thread Krystal Mok
Hi everyone, I'm sure somebody has seen this stack overflow before. My question is: is it expected (which should be documented to warn people not to do this), or is it considered a bug (which should be fixed)? Example: https://gist.github.com/rednaxelafx/930f8979473185cfc0a0 import java.util.*;