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

jdk1.4 regression: MessageFormat.equals() ignores formats setting

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      generic

      Description



      Name: dfR10049 Date: 07/25/2001



      java.text.MessageFormat.equals() ignores formats setting. It returns true even if
      MessageFormat objects have different set of formatters.

      This is the test demonstrating the bug:
      ------------------------------------------------------------------
      import java.text.*;


      public class Test {

          public static void main (String args[]){
           
              MessageFormat mf1 = new MessageFormat("pattern");
              MessageFormat mf2 = new MessageFormat("pattern");

              Format[] ff1 = {NumberFormat.getInstance()};
              Format[] ff2 = {DateFormat.getTimeInstance()};

              mf1.setFormats(ff1);
              mf2.setFormats(ff2);

              boolean eq = mf1.equals(mf2);
              System.out.println("equals returns: " + eq);
              if (eq)
                  System.out.println("Test failed");
              else
                  System.out.println("Test passed");

          }
      }
      ---------------------------------------------------------------------
      output from the test:

      #> java -version
      java version "1.4.0-beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b69)
      Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b69, mixed mode)

      #> java Test
      equals returns: true
      Test failed

      #> java Test
      equals returns: false
      Test passed

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

        Attachments

          Activity

            People

            Assignee:
            nlindenbsunw Norbert Lindenberg (Inactive)
            Reporter:
            fdasunw Fda Fda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: