This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
AbstractMap.toString() patch
- From: Mark Wielaard <mark at klomp dot org>
- To: java-patches at gcc dot gnu dot org
- Date: 07 Apr 2002 23:05:12 +0200
- Subject: AbstractMap.toString() patch
Hi,
The comment in AbstractMap.toString() is wrong (at least for the version
of the Sun JDK that I tested against). This patch makes the
implementation do what the javadoc says and seems to fix the last
remaining Collection failure in Mauve (yeah!).
2002-04-07 Mark Wielaard <mark@klomp.org>
* java/util/AbstractMap.java (toString): Explicitly use getKey() and
getValue().
OK to commit to branch/mainline?
Cheers,
Mark
P.S. My last post was also about AbstractMap (not HashMap.putAll() as
the Subject and ChangeLog entry implied). Sorry about that.
Index: java/util/AbstractMap.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/AbstractMap.java,v
retrieving revision 1.6
diff -u -r1.6 AbstractMap.java
--- java/util/AbstractMap.java 22 Jan 2002 22:40:38 -0000 1.6
+++ java/util/AbstractMap.java 7 Apr 2002 21:04:20 -0000
@@ -425,10 +425,10 @@
StringBuffer r = new StringBuffer("{");
for (int pos = size(); pos > 0; pos--)
{
- // Append the toString value of the entries rather than calling
- // getKey/getValue. This is more efficient and it matches the JDK
- // behaviour.
- r.append(entries.next());
+ Map.Entry entry = (Map.Entry) entries.next();
+ r.append(entry.getKey());
+ r.append('=');
+ r.append(entry.getValue());
if (pos > 1)
r.append(", ");
}