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

Receiver.send() does not work properly

    Details

    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: vtR10009 Date: 12/20/2001


        API spec for method Receiver.send() reads:
      "Sends a MIDI message and time-stamp to this receiver. If time-stamping is not
      supported by this receiver, the time-stamp value should be -1.
      Parameters:
        message - the MIDI message to send
        time-stamp - the time-stamp for the message, in microseconds.
      Throws:
        IllegalStateException - if the receiver is not open."

      But this method does not throw IllegalStateException exception as expected
      for closed Receiver which is linked with external MIDI output port.
      The same is true for the Receiver that is linked with the default synthesizer.
      But this exception is incorrectly thrown for unclosed receiver which is linked
      with Midi output port. Exception is thrown with the message: "Synthesizer
      is not open". So MIDI output port is linked directly with the default
      synthesizer. But API spec does not declare such behaivor.

      This bug causes failure of new JCK test:
       api/javax_sound/midi/Receiver/index.html#Receiver
      To reproduce the bug run the following tests with JDK 1.4.0-rc-b89:
      -------------------------------1 test.java 1--------------------------------
      import javax.sound.midi.*;

      public class test{
          public static void main(String args[])
          {
              boolean isFailed = false;
              Receiver rcvr;
              Synthesizer synt = null;
              ShortMessage shMsg = new ShortMessage();

              try {
                  synt = MidiSystem.getSynthesizer();
                  synt.open();
                  rcvr = synt.getReceiver();

                  rcvr.close();
                  shMsg.setMessage(ShortMessage.NOTE_ON, 0,60, 93);
                  rcvr.send( shMsg, -1 );
                  System.out.println("IllegalStateException was not thrown "
                          + "for Synthesizer's receiver!");
              } catch(MidiUnavailableException e) {
                  System.out.println("Midi unavailable, cannot test.");
                  return;
              } catch(InvalidMidiDataException ine) {
                  System.out.println("InvalidMidiDataException, cannot test.");
                  return;
              } catch(IllegalStateException ilEx) {
                  System.out.println("IllegalStateException was thrown. Ok.");
              } finally {
                  if (synt != null) synt.close();
              }
              try {
                  synt = MidiSystem.getSynthesizer();
                  synt.open();
                  rcvr = MidiSystem.getReceiver();

                  rcvr.close();
                  shMsg.setMessage(ShortMessage.NOTE_ON, 0,60, 93);
                  rcvr.send( shMsg, -1 );
                  System.out.println("IllegalStateException was not thrown "
                          + "for external MIDI output port!");
              } catch(MidiUnavailableException e) {
                  System.out.println("Midi unavailable, cannot test.");
                  return;
              } catch(InvalidMidiDataException ine) {
                  System.out.println("InvalidMidiDataException, cannot test.");
                  return;
              } catch(IllegalStateException ilEx) {
                  System.out.println("IllegalStateException was thrown. Ok.");
              } finally {
                  if (synt != null) synt.close();
              }
          }
      }
      ---------------------------Logs-------------------------------------------
      $ java -version
      java version "1.4.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b89)
      Java HotSpot(TM) Client VM (build 1.4.0-rc-b89, mixed mode)
      $ javac test.java
      $ java test
      IllegalStateException was not thrown for Synthesizer's receiver!
      IllegalStateException was not thrown for external MIDI output port!
      $
      -------------------------------2 test.java 2--------------------------------
      import javax.sound.midi.*;

      public class test{
          public static void main(String args[])
          {
              boolean isFailed = false;
              Receiver rcvr;
              ShortMessage shMsg = new ShortMessage();

              try {
                  rcvr = MidiSystem.getReceiver();

                  shMsg.setMessage(ShortMessage.NOTE_ON, 0,60, 93);
                  rcvr.send( shMsg, -1 );
                  rcvr.close();
              } catch(MidiUnavailableException e) {
                  System.out.println("Midi unavailable, cannot test.");
                  return;
              } catch(InvalidMidiDataException ine) {
                  System.out.println("InvalidMidiDataException, cannot test.");
                  return;
              } catch(IllegalStateException ilEx) {
                  ilEx.printStackTrace(System.out);
                  System.out.println("IllegalStateException was thrown incorrectly!");
              }
          }
      }
      ---------------------------Logs-------------------------------------------
      $ javac test.java
      $ java test
      java.lang.IllegalStateException: Synthesizer is not open.
              at
      com.sun.media.sound.AbstractPlayer$PlayerReceiver.send(AbstractPlayer.java:261)
              at test.main(test.java:14)
      IllegalStateException was thrown incorrectly!
      $
      --------------------------------------------------------------------------
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                duke J. Duke (Inactive)
                Reporter:
                vitcsunw Vitc Vitc (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: