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

(fmt) MissingFormatArgumentException.getFormatSpecifier() incorrect return value

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 5.0
    • core-libs
    • b17
    • generic
    • solaris_8
    • Verified

    Description

      The following test program illustrates that the format specifier returned
      by MissingFormatArgumentException.getFormatSpecifier() does not correspond
      to the one in the original format string as required by specification.
      In fact, the returned value isn't even a syntactically valid format specifier.

      ==========$ cat -n T.java
           1 import java.util.*;
           2 class T {
           3 public static void main(String[] args) {
           4 String spec = "%1$5.3s";
           5 try {
           6 String s2 = String.format(spec);
           7 } catch (MissingFormatArgumentException ex) {
           8 if (!ex.getFormatSpecifier().equals(spec))
           9 throw new Error(ex.getFormatSpecifier());
          10 System.out.println("passed");
          11 }
          12 }
          13 }
      ==========$ /usr/j2sdk1.5.0/bin/javac T.java
      ==========$ /usr/j2sdk1.5.0/bin/java T
      Exception in thread "main" java.lang.Error: 1$5.3s
              at T.main(T.java:9)
      ==========$

      Attachments

        Activity

          People

            bpassani Brandon Passanisi
            gafter Neal Gafter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: