java.util.Hashtable: difference between JDK and kaffe

Archie Cobbs archie at dellroad.org
Fri Jan 26 09:44:41 PST 2001


Ito Kazumitsu writes:
> Attached patch solves this problem.
> 
> bash$ diff -u ~/kaffe/cvs/kaffe/libraries/javalib/java/util/HashMap.java HashMap.java
> --- /home/ito/kaffe/cvs/kaffe/libraries/javalib/java/util/HashMap.java	Fri Apr  7 06:46:16 2000
> +++ HashMap.java	Fri Jan 26 17:22:35 2001
> @@ -234,7 +234,8 @@
>  
>  	private Entry find(Object key, int bucket) {
>  		for (Entry e = table[bucket]; e != null; e = e.next) {
> -			if (key == null ? e.key == null : key.equals(e.key)) {
> +			// if (key == null ? e.key == null : key.equals(e.key)) {
> +			if (e.key == null ? key == null : (e.key).equals(key)) {
>  				return e;

If x.equals(y) != y.equals(x) then all bets are off.  The
StringKey.equals() method is broken. JDK just happens to mask
the problem.

-Archie

__________________________________________________________________________
Archie Cobbs     *     Packet Design     *     http://www.packetdesign.com


More information about the kaffe mailing list