Object.toString() deviates from specification

Alexandre Oliva oliva at dcc.unicamp.br
Tue Sep 8 20:40:10 PDT 1998


--Multipart_Wed_Sep__9_03:40:10_1998-1
Content-Type: text/plain; charset=US-ASCII

Here's a patch that provides a correct implementation

-- 
Alexandre Oliva
mailto:oliva at dcc.unicamp.br mailto:aoliva at acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil

--Multipart_Wed_Sep__9_03:40:10_1998-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="object.toString.diff"
Content-Transfer-Encoding: 7bit

  Alexandre Oliva  <oliva at dcc.unicamp.br>

	* libraries/javalib/java/lang/Object.java (toString): implemented
	according to the JDK 1.[12] specification

--- libraries/javalib/java/lang/Object.java	Wed Aug  5 22:20:04 1998
+++ libraries/javalib/java/lang/Object.java	Wed Sep  9 03:36:38 1998
@@ -22,14 +22,7 @@
   }
   
   public String toString() {
-    /* According to the 1.0.2 docs this uses the hashCode, but:
-
-       "the hex. string printed is based on the hash code, but may not 
-        be the actual hash code"
-
-       Nice one, Sun! */
-    
-    return "@"+((new Integer(hashCode())).toString());
+    return getClass().getName()+'@'+Integer.toHexString(hashCode());
   }
   
   public final void wait(long timeout, int nanos) throws InterruptedException {

--Multipart_Wed_Sep__9_03:40:10_1998-1--


--GAA14380.905331924/grande.dcc.unicamp.br--





More information about the kaffe mailing list