patch for StringBuffer.java

David Reiss davidr42 at optonline.net
Tue Jul 3 14:18:36 PDT 2001


This patch fixes a problem in StringBuffer that would cause extra nulls
to be added to StringBuffers (and Strings after conversion) when using
StringBuffer.insert. It might do other bad things too; it only added
nulls for me. Note that you'll have to recompile Klasses.jar after
applying it.

The bug was caused by the patch in this message:
http://rpmfind.net/tools/Kaffe/messages/0421.html

It's attached and included inline here because it's so short.

--David Reiss



Index: libraries/javalib/java/lang/StringBuffer.java
===================================================================
RCS file: /pro/dynext/cvshome/kaffe/libraries/javalib/java/lang/StringBuffer.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 StringBuffer.java
--- StringBuffer.java	2001/06/08 21:00:38	1.1.1.1
+++ StringBuffer.java	2001/06/25 18:36:33
@@ -214,7 +214,7 @@
 	System.arraycopy(str, offset, buffer, index, len);
 
 	// Update used count
-	used += str.length;
+	used += len;
 	return this;
 }
 
-------------- next part --------------
Index: libraries/javalib/java/lang/StringBuffer.java
===================================================================
RCS file: /pro/dynext/cvshome/kaffe/libraries/javalib/java/lang/StringBuffer.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 StringBuffer.java
--- StringBuffer.java	2001/06/08 21:00:38	1.1.1.1
+++ StringBuffer.java	2001/06/25 18:36:33
@@ -214,7 +214,7 @@
 	System.arraycopy(str, offset, buffer, index, len);
 
 	// Update used count
-	used += str.length;
+	used += len;
 	return this;
 }
 


More information about the kaffe mailing list