diff options
-rw-r--r-- | libjava/ChangeLog | 7 | ||||
-rw-r--r-- | libjava/java/nio/CharBuffer.java | 11 |
2 files changed, 15 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index e39bbf8..552fa5d 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -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, diff --git a/libjava/java/nio/CharBuffer.java b/libjava/java/nio/CharBuffer.java index e2f8d5e..5499707d 100644 --- a/libjava/java/nio/CharBuffer.java +++ b/libjava/java/nio/CharBuffer.java @@ -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 ()); } /** |