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

FontMetrics.getStringBounds() documentation for parameter 'limit' is incorrect

XMLWordPrintable

    • 2d
    • b56
    • x86
    • windows_2000

      Name: rmT116609 Date: 07/17/2003


      A DESCRIPTION OF THE PROBLEM :
      The API documentation for FontMetrics.getStringBounds(char[] chars,int beginIndex,int limit,Graphics
      context)
      says:
       Parameters:
          chars - an array of characters
          beginIndex - the initial offset of the array of characters
          limit - the length of the array of characters
          context - the specified Graphics context

      However, the limit parameter is really an endIndex, not a length. That is,
      Sun's code is going to make a loop like:
      for (i = beginIndex; i < limit; i++)

      This applies to a couple other variants of getStringBounds() as well.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The description of the limit parameter should say:
      limit - the ending offset into the array of characters, exclusive
      ACTUAL -
      limit - the length of the array of characters

      URL OF FAULTY DOCUMENTATION :
      http://java.sun.com/j2se/1.4.2/docs/api/java/awt/FontMetrics.html
      (Incident Review ID: 191848)
      ======================================================================

            prr Philip Race
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: