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

Reading MidiMessage byte array fails in 1.4.2

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 1.4.2
    • client-libs
    • tiger
    • x86
    • windows_2000



      Name: rmT116609 Date: 07/14/2003


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      FULL OS VERSION :
      Microsoft Windows 2000 5.00.2195 Service Pack 2

      A DESCRIPTION OF THE PROBLEM :
      Reading the MidiMessage byte array results in a ArrayIndexOutOfBoundsException

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Running the code listed below will reproduce the error.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected result (and the result 1.4.1_01, 1.4.1_02 and 1.4.1_03 gives):

      mess[0]: -112 mess[1]: 72 mess[2]: 100
      mess[0]: -1 mess[1]: 47 mess[2]: 0
      ACTUAL -
      Read Method Exception: java.lang.ArrayIndexOutOfBoundsException: 2

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      ArrayIndexOutOfBoundsException: 2

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import javax.sound.midi.*;

      public class MidiTest
      {
      public static void main(String[] args)
      {
      MidiTest mt = new MidiTest();
      midiwrite();
      midiread();
      }

      static Track[] testmiditrack = new Track[1];

      static public void midiwrite()
      {
      try
      {
      Sequence testmidi = new Sequence(Sequence.PPQ, 480);
      testmiditrack[0] = testmidi.createTrack();
      ShortMessage sm = new ShortMessage();
      sm.setMessage(144, 72, 100);
      testmiditrack[0].add(new MidiEvent(sm, 0));
      MidiSystem.write(testmidi, 0, new File("miditest.mid"));
      }
      catch (Exception e)
      {
      System.out.println("Write Method Exception: " + e.toString());
      }
      }

      static public void midiread()
      {
      try
      {
      Sequence midi = MidiSystem.getSequence(new File("miditest.mid"));
      Track[] inTrack = midi.getTracks();

      for (int j = 0; j < inTrack[0].size(); j++)
      {
      MidiEvent event = inTrack[0].get(j);
      MidiMessage message = event.getMessage();
      byte[] mess = message.getMessage();
      System.out.println("mess[0]: " + (int)mess[0] + " mess[1]: " + mess[1] + " mess[2]: " + mess[2]);
      }
      }
      catch (Exception e)
      {
      System.out.println("Read Method Exception: " + e.toString());
      }
      }
      }


      ---------- END SOURCE ----------


      (Incident Review ID: 191357)
      ======================================================================

            fbomerssunw Florian Bomers (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: