JDK-4890405 : Reading MidiMessage byte array fails in 1.4.2
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-07-14
  • Updated: 2003-08-02
  • Resolved: 2003-08-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Description

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) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b14
14-06-2004

PUBLIC COMMENTS Reading MidiMessage byte array fails in 1.4.2
10-06-2004

EVALUATION ###@###.### 2003-07-21 Fixed in tiger. See also: 4851018: MidiMessage.getLength and .getData return wrong values.
21-07-2003