StringBuilder.append cannot throw IndexOutOfBoundsException

Martin Buchholz martinrb at google.com
Tue Jul 22 05:54:43 UTC 2008


This message contains bug report + fix.

The spec for StringBuilder.append has an erroneous
  @throws IndexOutOfBoundsException.

(StringBuffer.append does not have the same problem)

Here's the easy (except for the paperwork) fix:

diff --git a/src/share/classes/java/lang/StringBuilder.java
b/src/share/classes/java/lang/StringBuilder.java
--- a/src/share/classes/java/lang/StringBuilder.java
+++ b/src/share/classes/java/lang/StringBuilder.java
@@ -175,7 +175,6 @@
     }

     /**
-     * @throws IndexOutOfBoundsException {@inheritDoc}
      */
     public StringBuilder append(CharSequence s) {
         if (s == null)

Martin



More information about the core-libs-dev mailing list