OSDN Git Service

2003-05-10 Michael Koch <konqueror@gmx.de>
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 10 May 2003 07:41:59 +0000 (07:41 +0000)
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66656 138bc75d-0d04-0410-961f-82ee72b054a4

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

index e39bbf8..552fa5d 100644 (file)
@@ -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 e2f8d5e..5499707 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 ());
   }
   
   /**