-
Bug
-
Resolution: Fixed
-
P3
-
1.4.1
-
mantis
-
generic
-
generic
Name: vtR10009 Date: 06/17/2002
Specification for the method MetaMessage.setMessage from the
package javax.sound.midi reads:
"Sets the message parameters for a MetaMessage. Since only one status byte
value, 0xFF, is allowed for meta-messages, it does not need to be specified
here. Calls to getStatus return 0xFF for all meta-messages. The type argument
should be a valid value for the byte that follows the status byte in the
MetaMessage. The data argument should contain all the subsequent bytes of
the MetaMessage. In other words, the byte that specifies the type of MetaMessage
is not considered a data byte.
Parameters: type - meta-message type (must be less than 128)
data - the data bytes in the MIDI message
length - the number of bytes in the data byte array
Throws: InvalidMidiDataException - if the parameter values do not specify
a valid MIDI meta message InvalidMidiDataException"
But reference implementation does not verify the message data and as
a result InvalidMidiDataException is not thrown for incorrect meta-message
types and data length.
This bug causes failure of new JCK test:
api/javax_sound/midi/MetaMessage/index.html#CtorSet
To reproduce the bug run the following test with JDK build 1.4.1-beta-b14:
------------------------------- test.java --------------------------------
import javax.sound.midi.*;
public class test{
public static void main(String args[]) {
byte data[] = {(byte)0x02, (byte)0x1F, (byte)0x03};
int inv_types[] = { Integer.MIN_VALUE, Integer.MAX_VALUE};
byte data_t[] = { (byte)0x07, (byte)0x1F, (byte)0x04, (byte)0x5F, };
int types[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x20,
0x21, 0x2F, 0x51 };
String type_desriptions[] = { "Text", "Copyright", "Sequence/Track
Name",
"Instrument", "Lyric", "Marker", "Cue Point", "MIDI Channel",
"MIDI Port", "End of Track", "Tempo" };
boolean failed = false;
MetaMessage mMsg = new MetaMessage();
for (int i = 0; i < inv_types.length; i++) {
try {
mMsg.setMessage(inv_types[i], data, data.length);
System.err.println(" InvalidMidiDataException was not thrown!
");
System.err.println(" type: " + inv_types[i]);
failed = true;
} catch (InvalidMidiDataException inEx) {}
}
mMsg = new MetaMessage();
for (int i = 1; i < 8; i++) {
try {
mMsg.setMessage(types[i], data_t, data_t.length - 1);
System.err.println(" InvalidMidiDataException was not thrown!
");
System.err.println(" Invalid Midi message: " +
type_desriptions[i]);
failed = true;
} catch (InvalidMidiDataException inEx) {}
}
if( failed ) {
System.err.println("test failed");
System.exit(1);
} else {
System.out.println("OKAY");
System.exit(0);
}
}
}
---------------------------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-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)
InvalidMidiDataException was not thrown!
type: -2147483648
InvalidMidiDataException was not thrown!
Invalid Midi message: Copyright
InvalidMidiDataException was not thrown!
Invalid Midi message: Sequence/Track Name
InvalidMidiDataException was not thrown!
Invalid Midi message: Instrument
InvalidMidiDataException was not thrown!
Invalid Midi message: Lyric
InvalidMidiDataException was not thrown!
Invalid Midi message: Marker
InvalidMidiDataException was not thrown!
Invalid Midi message: Cue Point
InvalidMidiDataException was not thrown!
Invalid Midi message: MIDI Channel
test failed
--------------------------------------------------------------------------
======================================================================