-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
beta
-
sparc
-
solaris_2.6
Name: dfR10049 Date: 01/15/2001
java.net.Inet6Address.hashCode() always returns 0
Probably, the problem is due to copy-paste sources of
Inet6Address.java from InetAddress.java:
Inet6Address.java:
...
public int hashCode() {
return address;
}
but 'address' variable is not used in Inet6Address and always 0.
Please see an example demonstrating the bug below:
----------- IN6.java ----------------
import java.net.*;
import java.io.*;
public class IN6 {
public static void main (String args[]){
try {
Inet6Address address = (Inet6Address)InetAddress.getByName(args[0]);
System.out.println(address.toString());
System.out.println("hashCode: " + address.hashCode());
} catch (Exception e) {
System.out.println(" " + e);
}
}
}
#----------------- output from the test ----------------------
#> java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b46)
Java HotSpot(TM) Client VM (build 1.4beta-B45, mixed mode)
#> java IN6 1234::FFFF
/[1234::ffff]
hashCode: 0
#> java IN6 1234::FFFF:1.2.3.4
/[1234::ffff:102:304]
hashCode: 0
======================================================================