harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Hu (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4067) [classlib][luni] java.util.Hashtable has a problem with contains
Date Wed, 06 Jun 2007 10:42:26 GMT
[classlib][luni] java.util.Hashtable has a problem with contains

                 Key: HARMONY-4067
                 URL: https://issues.apache.org/jira/browse/HARMONY-4067
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Robert Hu

In  java.util.Hashtable.contains(Object value), there's a tiny bug compared with RI's behavior.
When we create two object of some special defined classes, A and B, and let :
A.equals(B) == true but B.equals(A) == false
This violate the rule of "equals" method, but we can actually create it.
Then, if we put B into a Hashtable as a value, but not put A, we can find that "contains(B)"
returns true but "contains(A)"  returns false.
Then, if we put A into a Hashtable as a value, but not put B, we can find that "contains(A)"
and "contains(B)" all return true.
But, Harmony does not have this feature.
Test code snap in a test method:
                      class Magic {
			private boolean illegal = false;
			private String value;
			public Magic(boolean illegal,String value) {
				this.illegal = illegal;
				this.value = value;
			public boolean equals(Object obj) {
				if(this == obj){
					return true;
				if(! (obj instanceof Magic) || this.value == null){
					return false;
				Magic t = (Magic)obj;
					return false;
				return this.value.equals(t.value);  
		Magic m1 = new Magic(false, "Same");
		Magic m2 = new Magic(true, "Same");
		Hashtable table = new Hashtable();
		table.put("key", m1);
		table = new Hashtable();
		table.put("key", m2);

RI: Pass
Harmony: Fail

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message