Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4932838

REGRESSION: undeclared IAE in MidiSystem.getReceiver()

XMLWordPrintable

    • b26
    • generic
    • generic

      Name: vtR10009 Date: 10/06/2003


      MidiSystem.getReceiver() method should not throw undeclared
      IllegalArgumentException instead of MidiUnavailableException.
      The same is true for method MidiSystem.getTransmitter().

      Note the test is passed by mantis (jdk1.4.2). So this is
      regression (of bug #4616517 probably).

      This bug causes failure of new JCK test:
        api/javax_sound/midi/MidiSystem/index.html#get[get005]
      To reproduce the bug run the following test with JDK build 1.5-b22:
      ------------------------------- test.java --------------------------------
      import javax.sound.sampled.*;
      import javax.sound.midi.*;

      public class test {

          static boolean isSoundAccessDenied = false;
          static {
              SecurityManager securityManager = System.getSecurityManager();
              if (securityManager != null) {
                  try {
                      securityManager.checkPermission(new AudioPermission("*"));
                  } catch (SecurityException e) {
                      isSoundAccessDenied = true;
                  }
              }
          }

          static final int STATUS_PASSED = 0;
          static final int STATUS_FAILED = 2;
          static final int STATUS_TEMP = 95;
          static java.io.PrintStream log = System.err;
          
          public static void main(String argv[]) { int testExitStatus = run(argv,
          System.out) + STATUS_TEMP; System.exit(testExitStatus); }

          public static int run(String argv[], java.io.PrintStream out) {
              boolean failed = false;
              Receiver recv;
              Transmitter transm;
          
              try {
                  recv = MidiSystem.getReceiver();
                  transm = MidiSystem.getTransmitter();
                  if (recv == null) {
                      log.println("No external Midi output port!");
                      failed = true;
                  }
                  if (transm == null) {
                      log.println("No external Midi input port!");
                      failed = true;
                  }
              } catch (MidiUnavailableException midiUnvEx) {
                  out.println("MidiUnavailableException was caught!");
                  return STATUS_PASSED;
              }
          
              if (failed == true) {
                  return STATUS_FAILED;
              } else {
                  out.println("Ok.");
                  return STATUS_PASSED;
              }
          }
          
      } // end of test class
      ---------------------------Logs-------------------------------------------
      novo101:tmp$ javac -d . test.java
      novo101:tmp$ $JDK15/bin/java -showversion -cp . test
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b22)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b22, mixed mode)

      Exception in thread "main" java.lang.IllegalArgumentException: Requested device
      not installed
              at javax.sound.midi.MidiSystem.getDefaultDevice(MidiSystem.java:926)
              at javax.sound.midi.MidiSystem.getReceiver(MidiSystem.java:223)
              at test.run(test.java:33)
              at test.main(test.java:24)
      novo101:tmp$ java -showversion -cp . test
      java version "1.4.2-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-rc-b25)
      Java HotSpot(TM) Client VM (build 1.4.2-rc-b25, mixed mode)

      Ok.
      --------------------------------------------------------------------------
      ======================================================================

            duke J. Duke
            vitcsunw Vitc Vitc (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: