When MidiSystem.getSoundbank(InputStream stream) method is invoked the MidiSystem class looks for all the SoundbankReaders available to the system.
The default SoundbankReader of the jdk, HsbParser gets activated and in turn calls HeadspaceSoundbank(InputStream stream) constructor.
Now apart from the default SoundbankReader, a third party implementation of some SoundbankReader (for eg. MsbReader) can also exists.
If MidiSystem.getSoundbank(InputStream stream) method is called to get a Soundbank which is not supported by the default SoundbankReader but is supported by MsbReader, it throws the following exceptions
java.io.IOException:Bad File Descriptor at
java.io.FileInputStream.read(Native Method) at
java.io.DataInputStream.readShort(DataInputStream.java:321) at
com.MID_Services.MsbReader.getSoundbank(MsbReader.java:86) at
javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:290) at
javax.sound.midi.MidiSystem.getSoundbank(MidiSystem.java:349) at
test0006.runTest(test0006.java:105) at TRTest.start(TRTest.java:137) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:30) at
sun.reflect.InflatableMethodAccessorImpl.invoke(InflatableMethodAccessorImpl.java:48) at
java.lang.reflect.Method.invoke(Method.java:306) at
TestRunner.runTest(TestRunner.java:261) at
TestRunner.compileAndRunTests(TestRunner.java:210) at
TestRunner.main(TestRunner.java:143)
MsbReader.java is a test implementation of SoundbankReader which is called by MidiSystem after HsbParser.java is invoked.