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

RFE: override equals() method in info classes

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic, x86
    • OS:
      generic, linux, windows_2000

      Description

      Name: vtR10009 Date: 04/05/2002


        Specification for the method MidiDevice.Info.equals() from the package
      javax.sound.midi reads:
      "Reports whether two objects are equal. Returns true if the objects
      are identical.
        Overrides: equals in class Object."
        
        But reference implementation does not override Object.equals() method
      and fails for identical instances. The same is true for hashCode()
      method.

      This bug causes failure of new JCK test:
        api/javax_sound/midi/MidiDevice/index.html#TypeCtor
        
      To reproduce the bug run the following test with JDK build 1.4.1-beta-b07:
      ------------------------------- test.java --------------------------------
      import javax.sound.midi.*;
      import java.io.*;


      public class test {

          public static void main(String args[]) {
              boolean failed = false;
              String name = "name";
              String vendor = "vendor";
              String descr = "description";
              String ver = "version";
              String sameName = "name";
              MidiDevice.Info dInfo1 = new DevInfo(name, vendor, descr, ver);
              MidiDevice.Info dInfo2 = new DevInfo(name, vendor, descr, ver);

              if (!dInfo1.equals(dInfo2)) {
                  System.out.println("These devices must be equal!");
                  System.out.println("Device:" + dInfo1);
                  System.out.println("Device:" + dInfo2);
                  failed = true;
              }
              dInfo2 = new DevInfo(sameName, vendor, descr, ver);
              if (!dInfo1.equals(dInfo2)) {
                  System.out.println("These devices must be equal too!");
                  System.out.println("Device:" + dInfo1);
                  System.out.println("Device:" + dInfo2);
                  failed = true;
              }
          
              if( failed == true ) {
                  System.out.println("Test failed!");
              } else {
                  System.out.println("OK.");
              }
              System.exit(0);
          }
      }

      class DevInfo extends MidiDevice.Info {
          DevInfo(String n,String v1,String d,String v2) {
          super(n,v1,d,v2);
          }
      }
      ---------------------------Logs-------------------------------------------
      novo101:templates$ javac test.java; java -showversion test
      java version "1.4.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b07)
      Java HotSpot(TM) Client VM (build 1.4.1-beta-b07, mixed mode)

      These devices must be equal!
      Device:name
      Device:name
      These devices must be equal too!
      Device:name
      Device:name
      Test failed!

      --------------------------------------------------------------------------
      ======================================================================

      ###@###.### 2002-09-25
      This RFE applies to the following classes:
      AudioFileFormat
      AudioFileFormat.Type
      AudioFormat
      AudioFormat.Encoding
      Control.Type
      DataLine.Info
      Line.Info
      LineEvent.Type
      Mixer.Info
      Port.Info
      ReverbType
      Instrument
      MetaMessage
      MidiDevice.Info
      MidiEvent
      MidiFileFormat
      MidiMessage
      Patch
      Sequencer.SyncMode
      ShortMessage
      SoundbankResource
      SysexMessage

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              amenkov Alex Menkov
              Reporter:
              vitcsunw Vitc Vitc (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: