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

[Fmt-*] Doc: Inconsistencies in handling of null FieldPosition in Format and subclasses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 9
    • 5.0
    • core-libs
    • generic
    • generic

      java.text.Format and its subclasses in java.text have format methods that accept FieldPosition arguments. The specifications and implementations disagree on the behavior resulting when a NullPointerException is passed in:

      Format.format(Object, StringBuffer, FieldPosition):
      specification: NPE; no implementation

      DateFormat.format(Object, StringBuffer, FieldPosition):
      specification: unspecified; implementation: pass-through

      DateFormat.format(Date, StringBuffer, FieldPosition):
      specification: unspecified; no implementation

      SimpleDateFormat.format(Date, StringBuffer, FieldPosition):
      specification: unspecified; implementation: NPE

      MessageFormat.format(Object, StringBuffer, FieldPosition):
      specification: unspecified; implementation: no exception

      MessageFormat.format(Object[], StringBuffer, FieldPosition):
      specification: unspecified; implementation: no exception

      NumberFormat.format(Object, StringBuffer, FieldPosition):
      specification: NPE; implementation: pass-through

      NumberFormat.format(double, StringBuffer, FieldPosition):
      specification: unspecified; no implementation

      NumberFormat.format(long, StringBuffer, FieldPosition):
      specification: unspecified; no implementation

      DecimalFormat.format(Object, StringBuffer, FieldPosition):
      specification: NPE; implementation: pass-through

      DecimalFormat.format(double, StringBuffer, FieldPosition):
      specification: unspecified; implementation: NPE

      DecimalFormat.format(long, StringBuffer, FieldPosition):
      specification: unspecified; implementation: NPE

      ChoiceFormat.format(double, StringBuffer, FieldPosition):
      specification: unspecified; implementation: no exception

      ChoiceFormat.format(long, StringBuffer, FieldPosition):
      specification: unspecified; implementation: pass-through

      The specifications and implementations need to be made consistent. Allowing null FieldPositions in general seems the best approach.
      ###@###.### 2005-03-03 02:45:20 GMT

            nishjain Nishit Jain
            nlindenbsunw Norbert Lindenberg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: