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

java.text.MessageFormat.parse fails for some patterns

    XMLWordPrintable

Details

    • 1.2beta4
    • sparc
    • solaris_2.5
    • Verified

    Description



      Name: dfC67450 Date: 03/11/98



      Object[] java.text.MessageFormat.parse(String text, ParsePosition pp)
      works incorrectly with patterns containing multiple occurences of the
      same argument like "{0}, {0}, {0}". With this pattern the string
      "x, y, z" is incorrect but method doesn't reject it.

      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.text.*;

      public class Test {
          public static void main (String args[]){
              MessageFormat mf = new MessageFormat("{0}, {0}, {0}");
              String forParsing = "x, y, z";
              Object[] objs = mf.parse(forParsing, new ParsePosition(0));
              System.out.println("pattern: \"" + mf.toPattern() + "\"");
              System.out.println("text for parsing: \"" + forParsing + "\"");
              System.out.println("argument0: \"" + objs[0] + "\"");
          }
      }

      ---------Output from the test ---------------------
      pattern: "{0}, {0}, {0}"
      text for parsing: "x, y, z"
      argument0: "z"
      --------------------------------------------------

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

      Attachments

        Activity

          People

            duke J. Duke
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: