2003-05-10 Michael Koch <konqueror@gmx.de>
authorMichael Koch <konqueror@gmx.de>
Sat, 10 May 2003 07:41:59 +0000 (07:41 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Sat, 10 May 2003 07:41:59 +0000 (07:41 +0000)
* java/nio/CharBuffer.java
(put): Fixed precondtion check.
(toString): Make it work without backing array.
(put): Skip one level of method calling.

From-SVN: r66656

libjava/ChangeLog
libjava/java/nio/CharBuffer.java

index e39bbf83d4f10e9465027eb88f4472cd159444c9..552fa5d99965df8e24eb0008d381b755e4b7b12a 100644 (file)
@@ -1,3 +1,10 @@
+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,
index e2f8d5e130a910312dad4d3533163eb9e75f227c..5499707d9fa069cbbe19bacbe57f02db14441892 100644 (file)
@@ -177,7 +177,7 @@ public abstract class CharBuffer extends Buffer
     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 abstract class CharBuffer extends Buffer
    */
   public String toString ()
   {
-    return new String (array (), position (), length ());
+    if (hasArray ())
+      return new String (array (), position (), length ());
+
+    char[] buf = new char [length ()];
+    get (buf);
+    return new String (buf);
   }
 
   /**
@@ -409,7 +414,7 @@ public abstract class CharBuffer extends Buffer
    */
   public final CharBuffer put (String str)
   {
-    return put (str, 0, str.length ());
+    return put (str.toCharArray (), 0, str.length ());
   }
   
   /**