-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0, 5.0
-
b26
-
generic, sparc
-
generic, solaris_1
-
Verified
Name: vtR10009 Date: 01/29/2002
API spec for the method javax.sound.midi.MidiSystem.getSoundbank(File)
reads:
"Throws:
InvalidMidiDataException - if the File does not point to valid MIDI soundbank
data recognized by the system
IOException - if an I/O error occurred when loading the soundbank".
But this method throws unexpected IOException instead of
InvalidMidiDataException for invalid soundBank files.
This bug causes failure of new JCK test:
api/javax_sound/midi/MidiSystem/index.html#getFile
To reproduce the bug 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 = "invalid.mid";
String testdir = args[0];
boolean failed = false;
try {
File file = new File(testdir, fName);
Soundbank sBank = MidiSystem.getSoundbank(file);
System.err.println("InvalidMidiDataException was not thrown!");
failed = true;
} catch (InvalidMidiDataException invMidiEx) {
} 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");
}
}
}
---------------------------Logs-------------------------------------------
$ javac test.java
$ java test .
Unexpected IOException was caught!
mark/reset not supported
java.io.IOException: mark/reset not supported
at java.io.InputStream.reset(InputStream.java:329)
at
com.sun.media.sound.HeadspaceSoundbank.initialize(HeadspaceSoundbank.java:243)
at
com.sun.media.sound.HeadspaceSoundbank.<init>(HeadspaceSoundbank.java:80)
at com.sun.media.sound.HsbParser.getSoundbank(HsbParser.java:66)
at javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:287)
at javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:346)
at test.main(test.java:12)
Test failed!
^C$ cat invalid.mid
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
$ java -version
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)
--------------------------------------------------------------------------
======================================================================
API spec for the method javax.sound.midi.MidiSystem.getSoundbank(File)
reads:
"Throws:
InvalidMidiDataException - if the File does not point to valid MIDI soundbank
data recognized by the system
IOException - if an I/O error occurred when loading the soundbank".
But this method throws unexpected IOException instead of
InvalidMidiDataException for invalid soundBank files.
This bug causes failure of new JCK test:
api/javax_sound/midi/MidiSystem/index.html#getFile
To reproduce the bug 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 = "invalid.mid";
String testdir = args[0];
boolean failed = false;
try {
File file = new File(testdir, fName);
Soundbank sBank = MidiSystem.getSoundbank(file);
System.err.println("InvalidMidiDataException was not thrown!");
failed = true;
} catch (InvalidMidiDataException invMidiEx) {
} 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");
}
}
}
---------------------------Logs-------------------------------------------
$ javac test.java
$ java test .
Unexpected IOException was caught!
mark/reset not supported
java.io.IOException: mark/reset not supported
at java.io.InputStream.reset(InputStream.java:329)
at
com.sun.media.sound.HeadspaceSoundbank.initialize(HeadspaceSoundbank.java:243)
at
com.sun.media.sound.HeadspaceSoundbank.<init>(HeadspaceSoundbank.java:80)
at com.sun.media.sound.HsbParser.getSoundbank(HsbParser.java:66)
at javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:287)
at javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:346)
at test.main(test.java:12)
Test failed!
^C$ cat invalid.mid
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
This is not a MIDI file.
$ java -version
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)
--------------------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4496016 java.io.IOException: at com.sun.media.sound.HeadspaceSoundbank.initialize()
-
- Closed
-