JDK-4685396 : method Synthesizer.remapInstrument() does not work
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 1.4.1
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2002-05-15
  • Updated: 2017-05-16
  • Resolved: 2006-07-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
6 b80Fixed
Related Reports
Duplicate :  
Relates :  
Name: vtR10009			Date: 05/15/2002

  Spec for Synthesizer.remapInstrument() from the package
javax.sound.midi reads:
" Remaps an instrument. Instrument to takes the place of instrument from. 
For example, if from was located at bank number 2, program number 11, 
remapping causes that bank and program location to be occupied instead 
by to. Instrument from is unloaded.
     from - instrument to be replaced
     to - new instrument to be used in place of the old instrument
     true if the instrument could be remapped, false otherwise."

But default synthesizer does not unload "from" instrument and load "to"
instead. Such behavior contradicts to the spec.

This bug causes failure of new JCK test:
To reproduce the bug run the following test with JDK build with 1.4.1-beta-b11:
------------------------------- test.java --------------------------------
import javax.sound.midi.*;

public class test{
    public static boolean isInstrumentExist(Instrument inst, Instrument[] 
instArr) {
        for (int i = 0; i < instArr.length; i++) {
            if (inst.equals(instArr[i])) return true;
        return false;
    public static void main(String args[]) {
        boolean failed = false;
        Synthesizer synth = null;
        Instrument[] instrs, avInstrs;
        Instrument from, to;
        Soundbank sBank;
        try {
            synth = MidiSystem.getSynthesizer();
            instrs = synth.getLoadedInstruments();
            for (int i = 0; i < instrs.length; i++) {
            if (instrs.length != 0) {
                System.err.println(" Non-zero length array!");
                failed = true;
                for (int i = 0; i < instrs.length; i++) {
                    System.err.println("Instrument: " + instrs[i]);
            sBank = synth.getDefaultSoundbank();
            if (sBank == null) {
                System.err.println("No default bank. Ok.");
            instrs = sBank.getInstruments();
            if (synth.loadAllInstruments(sBank)) {
                synth.unloadInstrument(instrs[instrs.length - 1]);
                from = instrs[0];
                to = instrs[instrs.length - 1];
                if (!synth.remapInstrument(from, to)) {
                    System.err.println(" Instrument does not mapped!");
                    failed = true;
                } else {
                    if (isInstrumentExist(from, synth.getLoadedInstruments())) {
                        System.err.println(" Instrument from is not unloaded.");
                        failed = true;
                    if (!isInstrumentExist(to, synth.getLoadedInstruments())) {
                        System.err.println(" Instrument to is not correctly" +
                        failed = true;
        } catch (MidiUnavailableException mue) {
            System.err.println("MidiUnavailableException was thrown: " + mue);
        } finally {
            if (synth != null) synth.close();
        if (failed == true) {
        } else {
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-b11)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b11, mixed mode)

 Instrument from is not unloaded.
 Instrument to is not correctly mapped.


EVALUATION It looks like native code remaps the instrument and after remap new instrument sounds instead replaced one, but java implementation doesn't change its instrument list accordingly. Also implementation doesn't unload "from" instrument. It's too risky to fix in mustang, retargeting to dolphin.

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon

PUBLIC COMMENTS method ramapInstrument does not work

EVALUATION ###@###.### 2002-05-15 Implementations should have the possibility to not implement this feature. Committing to Mantis. ###@###.### 2002-11-25 Further investigation showed that this is really an implementation problem - it seems that the implementation does not really remaps the instrument, but reports true. Committing to Tiger. The TCK test should be adapted to not fail when remapIntrument returns false. ###@###.### 2003-09-22 No time for tiger. Commit to dragon.