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

java.awt.MenuShortcut defines equals(MenuShortcut) instead of equals(Object)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta4
    • CPU:
      sparc
    • OS:
      solaris_2.5, solaris_2.6
    • Verification:
      Not verified

      Description



      Name: mgC56079 Date: 09/17/97



        The java.awt.MenuShortcut class defines 'public boolean equals(MenuShortcut)'
      method instead of overriding 'public boolean Object.equals(Object)' method.

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



      --- Here is the test demonstrating the bug ---
       
      import java.awt.MenuShortcut;
      public class MS {
        public static void main(String[] args) {
          MenuShortcut ms=new MenuShortcut(0);
          MenuShortcut ms1=new MenuShortcut(0);
          Object ms1again=ms1;
          System.out.println(ms.equals(ms1)); //returns true
          System.out.println(ms.equals(ms1again)); //returns false, expecting true
        }
      }
      --- Here is the output of the test ---
      %java MS
      true
      false
       
      --- Here is more interesting example ---
       
      import java.awt.MenuShortcut;
      import java.util.Vector;
       
      public class MS {
        public static void main(String[] args) {
          Vector v=new Vector();
          MenuShortcut ms=new MenuShortcut(0);
          v.addElement(ms);
          /*
           ....
           */
          MenuShortcut ms1=new MenuShortcut(0);
          System.out.println("ms1.equals(ms1):"+ms1.equals(ms1));
          System.out.println("equals returns true so expecting v.indexOf(ms1) to return 0 according to the JLS 21.11.27");
          System.out.println(v.indexOf(ms1));
          if (v.indexOf(ms1)==-1)
            System.out.println("MenuShortcut not found in vector");
        }
      }
      --- Here is the output of the test ---
      % java MS
      ms1.equals(ms1):true
      equals returns true so expecting v.indexOf(ms1) to return 0 according to the JLS 21.11.27
      -1
      MenuShortcut not found in vector

      ###@###.### 1997-12-04

        Attachments

          Activity

            People

            Assignee:
            dmendenhsunw David Mendenhall (Inactive)
            Reporter:
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: