Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit4.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!53ab2750!not-for-mail From: "Jan Burse" Subject: Re: hashCode Message-ID: <5027F2CB.56705.calajapr@time.synchro.net> X-Comment-To: Joshua Cranmer Newsgroups: comp.lang.java.programmer In-Reply-To: <5027F2CB.56703.calajapr@time.synchro.net> References: <5027F2CB.56703.calajapr@time.synchro.net> X-FTN-AREA: COMP.LANG.JAVA.PROGRAMMER X-FTN-MSGID: 1:261/38 1fc6688e X-FTN-REPLY: 1:261/38 51718d47 Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.16a-Win32 NewsLink 1.98] Lines: 31 Date: Sun, 12 Aug 2012 18:58:20 GMT NNTP-Posting-Host: 69.21.70.65 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1344797900 69.21.70.65 (Sun, 12 Aug 2012 13:58:20 CDT) NNTP-Posting-Date: Sun, 12 Aug 2012 13:58:20 CDT Organization: tds.net Xref: csiph.com comp.lang.java.programmer:17760 To: Joshua Cranmer From: Jan Burse Joshua Cranmer schrieb: > > In the default case, a.hashCode() == b.hashCode() only when a == b (this > definitely holds true with 32-bit machines and I'm pretty sure it still > holds true with 64-bit machines, but I'd have to reverify the JVM source > code to be certain). Not at all. Even not for 32-bit machines. Not only because the hashCode() usually uses less than 32 bits. But also for other reasons, namely the internal algorithm how the hash is produced (although the below bug doesn't reveal much internals): http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6321873 But in the bottom of the above bug you can find code that searches for a clash. It can take quite a while, but it is not excluded. This is what a sample run produced according to the bug: 62028120: java.lang.Object@9cab16 - java.lang.Object@9cab16 So the 62028120-th new Object produced the same hashcode. So --- BBBS/Li6 v4.10 Dada-1 * Origin: Prism bbs (1:261/38) --- Synchronet 3.16a-Win32 NewsLink 1.98 Time Warp of the Future BBS - telnet://time.synchro.net:24