This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: java.nio.CharBuffer fixes


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I commited the attached patch to trunk to fix some bugs in 
java.nio.CharBuffer.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+vK32WSOgCCdjSDsRAraQAJ9AfSoPzM+ybzg0X5x4VzBGmej+cACdH0GK
8cCAobNnOWTAEZ4InREnKLQ=
=/P+t
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1884
diff -u -b -B -r1.1884 ChangeLog
--- ChangeLog	10 May 2003 07:12:47 -0000	1.1884
+++ ChangeLog	10 May 2003 07:34:19 -0000
@@ -1,5 +1,12 @@
 2003-05-10  Michael Koch  <konqueror@gmx.de>
 
+	* java/nio/CharBuffer.java
+	(put): Fixed precondtion check.
+	(toString): Make it work without backing array.
+	(put): Skip one level of method calling.
+
+2003-05-10  Michael Koch  <konqueror@gmx.de>
+
 	* java/security/Identity.java,
 	java/security/IdentityScope.java,
 	java/security/Key.java,
Index: java/nio/CharBuffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/CharBuffer.java,v
retrieving revision 1.8
diff -u -b -B -r1.8 CharBuffer.java
--- java/nio/CharBuffer.java	2 May 2003 05:35:57 -0000	1.8
+++ java/nio/CharBuffer.java	10 May 2003 07:34:19 -0000
@@ -177,7 +177,7 @@
     if (offset < 0
         || offset >= src.length
         || length < 0
-        || length >= (src.length - offset))
+        || length > (src.length - offset))
       throw new IndexOutOfBoundsException ();
      
     // Put nothing into this buffer when not enough space left.
@@ -361,7 +361,12 @@
    */
   public String toString ()
   {
+    if (hasArray ())
     return new String (array (), position (), length ());
+
+    char[] buf = new char [length ()];
+    get (buf);
+    return new String (buf);
   }
 
   /**
@@ -409,7 +414,7 @@
    */
   public final CharBuffer put (String str)
   {
-    return put (str, 0, str.length ());
+    return put (str.toCharArray (), 0, str.length ());
   }
   
   /**

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]