Hi all.
There seems to be a really serious bug in the System.identityHashCode()
method in all > JDK 1.2 releases derived from Sun code. The
problem only shows up in "high load" situations. Basically,
two different Java objects of the same class can return the
exact same unique id from the System.identityHashCode() method.
I have a test that reproduces this bug every time in > JDK 1.2 JVMs.
Steps to reproduce:
1: Download Jacl (Tcl shell implemented in Java):
ftp://ftp.scriptics.com/pub/tcl/java/jacl126-noarch.zip
2: unzip jacl126-noarch.zip, the following files are created:
lib/tcljava.jar
lib/jacl.jar
Readme.jacl
3: Set your CLASSPATH to include the two jar files and ".".
setenv CLASSPATH `pwd`/lib/tcljava.jar:`pwd`/lib/jacl.jar:.
4: Download the crash test from:
http://www.mail-archive.com/tcljava@scriptics.com/msg00847/ReflectCrash.zip
5: unzip ReflectCrash.zip, the following files are created:
ReflectCrash
ReflectCrash/MyCmd.java
ReflectCrash/MyObjects.java
ReflectCrash/mytest.tcl
ReflectCrash/SomeObject.java
ReflectCrash/MyCmd.class
ReflectCrash/SomeObject.class
ReflectCrash/MyObjects.class
ReflectCrash/mytest.results
6: cd to the ReflectCrash and run the crash test.
java tcl.lang.Shell mytest.tcl
This test case will create a bunch of Java objects
and hash the objects into a Hashtable based on the
class name and the uid returned by System.identityHashCode().
For example, "SomeObject.1512497281" would map to an instance
of the class SomeObject with the uid 1512497281 as returned
by System.identityHashCode().
If two different objects return the same hash code,
they will overlap. This causes an assert to fail
and a message like this will be printed:
Exception in thread "main" tcl.lang.TclRuntimeError:
(find) table entry "SomeObject.1512497281" mapped to an invalid entry,
I have been able to reproduce this error in > JDK 1.2
releases from Sun (including blackdown and IBM ports).
This also happens on all platforms, NT, 95, Linux, and
so on. This error does not show up with JDK 1.1.8 from
blackdown (or any other JDK 1.1 JVMs for that matter).
So far, I have identified a couple of workarounds. I
could just require that everyone use a JDK 1.1 release.
I could also require that people use Kaffe (it does not
have the bug). The final option would be to write my
own UID() method that would try to do something to
detect a duplicate id and generate a unique one.
Each of the above options is sub-optimal.
Comments anyone?
Mo DeJong
Red Hat Inc
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]