Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4330484

(spec str) StringBuffer.append spec doesn't say how capacity is affected

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs
    • sparc
    • solaris_2.6

      Name: ksC84122 Date: 04/14/2000



      The javadoc for the following methods doesn't say how capacity is affected:
          public StringBuffer append(Object obj)
          public StringBuffer append(String str)
          public StringBuffer append(char str[])
          public StringBuffer append(char str[], int offset, int len)
          public StringBuffer append(boolean b)
          public StringBuffer append(char c)
          public StringBuffer append(int i)
          public StringBuffer append(long l)
          public StringBuffer append(float f)
          public StringBuffer append(double d)

      However, the affect on capacity was described in the JLS 1.0
      (pp 552-554, items 20.13.12-20.13.21)


      For example, 1.3 API spec (javadoc) says:
          public StringBuffer append(String str)

          Appends the string to this string buffer.

          The characters of the String argument are appended, in order,
          to the contents of this string buffer, increasing the length of
          this string buffer by the length of the argument. If str is null,
          then the four characters "null" are appended to this string buffer.

          Let n be the length of the old character sequence, the one contained
          in the string buffer just prior to execution of the append method.
          Then the character at index k in the new character
          sequence is equal to the character at index k in the old character
          sequence, if k is less than n; otherwise, it is equal to the character
          at index k-n in the argument str.

      On the other hand, JLS 1.0 says that ensureCapacity method is to be called:
          20.13.13 public StringBuffer append(String str)
       
          The characters of the String argument are appended, in order, to the
          contents of this string buffer, increasing the length of this string
          buffer by the length of the argument. If str is null, then the four
          characters "null" are appended to this string buffer.
      *** The method ensureCapacity (?20.13.7) is first called with this new ***
      *** string buffer length as its argument. A reference to this StringBuffer ***
      *** object is returned. ***

          Let n be the length of the old character sequence, the one contained in
          the string buffer just prior to execution of the append method. Then the
          character at index k in the new character sequence is equal to the
          character at index k in the old character sequence, if k is less than n;
          otherwise, it is equal to the character at index k-n in the argument str.


      ======================================================================

            Unassigned Unassigned
            skosunw Sko Sko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: