Name: vtR10009 Date: 06/17/2002
Specification for the method ShortMessage.setMessage from the
package javax.sound.midi reads:
"public void setMessage(int command, int channel, int data1, int data2)
Sets the short message parameters for a channel message which takes one or
two data bytes. If the message only takes one data byte, the second data byte
value passed should be 0."
But reference implementation does not verify the data bytes and as a
result InvalidMidiDataException is not thrown for incorrect one-byte
messages.
This bug causes failure of new JCK test:
api/javax_sound/midi/ShortMessage/index.html#SetMessage
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[]) {
ShortMessage se = new ShortMessage();
boolean failed = false;
int[] ch_cmds = { ShortMessage.CHANNEL_PRESSURE,
ShortMessage.PROGRAM_CHANGE };
for (int i = 0; i < ch_cmds.length; i++) {
try {
se = new ShortMessage();
se.setMessage(ch_cmds[i], 2, 3, 3);
System.err.println(" InvalidMidiDataException was not thrown: "
+ ch_cmds[i] + " [" + 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: 208 [0]
InvalidMidiDataException was not thrown: 192 [1]
test failed
--------------------------------------------------------------------------
======================================================================
###@###.### 2003-10-23
checked in fix