Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4890405
Votes 0
Synopsis Reading MidiMessage byte array fails in 1.4.2
Category java:classes_sound
Reported Against 1.4.2
Release Fixed 1.5(tiger)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs 4851018
Submit Date 14-JUL-2003
Description
Reading MidiMessage byte array fails in 1.4.2




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) 
======================================================================
Work Around
N/A
Evaluation
 xxxxx@xxxxx  2003-07-21
	Fixed in tiger. See also: 4851018: MidiMessage.getLength and .getData return wrong values.
Comments
  
  Include a link with my name & email   

Submitted On 22-JUL-2003
smmk
Well done tiger..kudoos 


Submitted On 11-JUN-2004
svensture
What exactly does this mean?:
State  Closed, fixed

I'm running 1.4.2_04 and it is still there. When will there be a functional release?



PLEASE NOTE: JDK6 is formerly known as Project Mustang