-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
hopper
-
generic
-
generic
Name: vtR10009 Date: 02/08/2002
API spec for the method getByteLength() of the class
javax.sound.midi.MidiFileFormat reads:
"Obtains the length of the MIDI file, expressed in 8-bit bytes."
But MidiSystem.getMidiFileFormat() creates MidiFileFormat instance that
contains wrong length and method getByteLength() returns -1.
This bug causes failure of new JCK test:
api/javax_sound/midi/MidiSystem/index.html#getFile
To reproduce the bug put the file "metatest.mid" in current dir and run the
following test with JDK 1.4.0-rc-b90 build:
------------------------------- test.java --------------------------------
import javax.sound.midi.*;
import java.io.*;
public class test{
public static void main(String args[])
{
String fName = "metatest.mid";
boolean failed = false;
try {
File file = new File(args[0], fName);
MidiFileFormat mff = MidiSystem.getMidiFileFormat(file);
if (mff.getByteLength() != file.length()) {
System.err.println("Wrong length in format: " +
mff.getByteLength());
System.err.println("Actual length, in bytes: " + file.length());
failed = true;
}
if (mff.getResolution() != 0xF0) {
System.err.println("Wrong Resolution in format: " +
mff.getResolution());
failed = true;
}
if (mff.getType() != 1) {
System.err.println("Wrong format type: " + mff.getType());
failed = true;
}
} catch (InvalidMidiDataException invMidiEx) {
System.err.println("Caught InvalidMidiDataException: " + invMidiEx);
invMidiEx.printStackTrace();
failed = true;
} catch (IOException ioEx) {
System.err.println("Unexpected IOException was caught!");
System.err.println(ioEx.getMessage());
ioEx.printStackTrace();
failed = true;
}
if( failed ) {
System.err.println("Test failed!");
} else {
System.out.println("OKAY");
}
System.exit(0);
}
}
---------------------------Logs-------------------------------------------
$ javac test.java
$ java -showversion test .
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b90)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b90, mixed mode)
Wrong length in format: -1
Actual length, in bytes: 4252
Test failed!
--------------------------------------------------------------------------
======================================================================
- relates to
-
JDK-4670160 Sound: MidiFileFormat spec does not mention UNKNOWN_LENGTH
-
- Resolved
-