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

method Mixer.getLine throws unexpected ArrayIndexOutOfBoundsException

    Details

    • Subcomponent:
    • Resolved In Build:
      hopper
    • CPU:
      x86
    • OS:
      windows_nt

      Description



      Name: ipR10067 Date: 07/11/2002


      Method javax.sound.sampled.Mixer.getLine(Line.Info info) throws
      unexpected ArrayIndexOutOfBoundsException on Windows NT (and Win 2000)
      if no sound card installed in the system or sound device is disabled
      (through "control panel").


      Run the following test example to reproduce the bug:

      ======================== getLineTests.java ===================================
      package test_sampled_Mixer;
      import javax.sound.sampled.*;

      public class getLineTests {

          public static void main(String argv[]) {
              getLineTests test = new getLineTests();
              test.run();
              System.exit(0);
          }

          public void run() {
          
              Mixer.Info[] installedMixersInfo = AudioSystem.getMixerInfo();
              
                
              if ( installedMixersInfo.length == 0 ) {
                  System.out.println("there are no mixers installed on the system. It's OK");
                  return;
              }
          
              Mixer testedMixer = null;

              for (int i=0; i < installedMixersInfo.length; i++) {
                  try {
                      testedMixer = AudioSystem.getMixer(installedMixersInfo[i]);
                      System.out.println("Mixer = " + testedMixer);

                  } catch (SecurityException securityException) {
                       System.out.println("installed Mixer is unavailable because of security restrictions");
                       return;
                  } catch (Throwable thrown) {
                      System.out.println("AudioSystem.getMixer() threw unexpected exception:");
                      thrown.printStackTrace(System.out);
                      return;
                  }
          
                  Line.Info producedLineInfo[] = null;
                  try {
                      producedLineInfo = testedMixer.getSourceLineInfo();
                  } catch (Throwable thrown) {
                      System.out.println("Mixer.getSourceLineInfo() threw unexpected exception:");
                      thrown.printStackTrace(System.out);
                      return;
                  }

                  System.out.println(" length of producedLineInfo =" + producedLineInfo.length);

                  for (int j=0; j < producedLineInfo.length; j++) {

                      Line.Info testLineInfo = producedLineInfo[j];
                      System.out.println(" Line.Info = " + testLineInfo);

                      Line producedLine;

                      try {
                          producedLine = testedMixer.getLine(testLineInfo);
                          System.out.println(" producedLine = " + producedLine);

                      } catch (LineUnavailableException lineUnavailableException) {
                          System.out.println("line is not available due to resource restrictions");
                          return;
                      } catch (SecurityException securityException) {
                           System.out.println("line is not available due to security restrictions");
                           return;

                      } catch (Throwable thrown) {
                          System.out.println(" testedMixer.getLine(testLineInfo) threw unexpected exception:");
                          thrown.printStackTrace(System.out);
                          return;
                      }

                      if ( producedLine == null ) {
                          System.out.println(" Mixer.getLine(Line.Info) failed:");
                          System.out.println(" returned Line = null");
                          return;
                      }
                
                  } //for j

              } //for i

          return;

          }
          
      }

      class GetLineLine implements Line {

          public void addLineListener(LineListener listener) {
          }

          public void close() {
          }

          public Control getControl(Control.Type control) {
              return null;
          }

          public Control[] getControls() {
              return new Control[0];
          }

          public Line.Info getLineInfo() {
              return null;
          }

          public boolean isOpen() {
              return false;
          }

          public boolean isControlSupported(Control.Type control) {
              return false;
          }

          public void open() {
          }

          public void removeLineListener(LineListener listener) {
          }
      }


      ============================log=======================================

      V:>set CLASSPATH=.

      V:>D:\Java\JDK1.492\win\bin\javac -d . getLineTests.java

      V:>D:\Java\JDK1.492\win\bin\java -version
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      V:>D:\Java\JDK1.492\win\bin\java test_sampled_Mixer.getLineTests
      Mixer = com.sun.media.sound.HeadspaceMixer@dd20f6
        length of producedLineInfo =2
        Line.Info = interface SourceDataLine supporting 8 audio formats
          producedLine = com.sun.media.sound.MixerSourceLine@e83912
        Line.Info = interface Clip supporting 8 audio formats, and buffers of 0 to 4194304 bytes
          producedLine = com.sun.media.sound.MixerClip@d8957f
      Mixer = com.sun.media.sound.SimpleOutputDevice@fa3ac1
        length of producedLineInfo =1
        Line.Info = interface SourceDataLine
       testedMixer.getLine(testLineInfo) threw unexpected exception:
      java.lang.ArrayIndexOutOfBoundsException
      at com.sun.media.sound.SimpleOutputDevice.getLine(SimpleOutputDevice.java:321)
      at test_sampled_Mixer.getLineTests.run(getLineTests.java:58)
      at test_sampled_Mixer.getLineTests.main(getLineTests.java:9)

      ======================================================================


      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              fbomerssunw Florian Bomers (Inactive)
              Reporter:
              ipsunw Ip Ip (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: