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

java.text.MessageFormat has a subtle flaw

XMLWordPrintable

    • x86
    • windows_nt



      Name: rm29839 Date: 10/29/97


      java.text.MessageFormat has an array of objects
      to format, along with an array of type java.text.Format
      objects which are used to format the arguments in
      the first array.

      The problem is that the array indexes in these
      two arrays do not correspond to each other.

      The objects in the first array are placed into the
      string at the positions indicating in the string
      by the curly brace + integer + curly brace notation.

      Contrary to this, the format objects operate on
      the arguments in the string, as they appear in the
      string.

      This probably isn't new to you since it was in
      the documentation this way. I think the two arrays
      should correspond for the following reason:

      Given the class Foo as one of the arguments to be
      formatted, and FooFormatter, my own extension
      of java.text.Formatter, as one of the formatters,
      I have no way of ensuring that FooFormatter
      will be used to format Foo unless I hand craft my
      message string or eliminate any other arguments for
      that part of the string.
      (Review ID: 14483)
      ======================================================================

            duke J. Duke
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: