-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2fcs
-
sparc
-
solaris_2.5
-
Verified
Name: mgC56079 Date: 08/17/98
JLS 1.0 item 20.1.4 says:
If two objects are equal according to the equals method (20.1.3),
then calling the hashCode method on each of the two objects must
produce the same integer result.
This is not true for java.util.jar.Manifest objects.
Manifest class should override both equals() and hashCode() methods.
Here is the test demonstrating the bug (should print 'true' in both cases):
-----------------ManifestTest.java------------------------
import java.util.jar.*;
import java.io.*;
public class ManifestTest {
public static void main(String args[]) {
Manifest manifest1=new Manifest();
Manifest manifest2=(Manifest)(manifest1.clone());
System.out.println(manifest1.equals(manifest2));
System.out.println(manifest1.hashCode()==manifest2.hashCode());
}
}
-----------------sample run (jdk1.2fcsF)------------------------
% java ManifestTest
true
false
======================================================================