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

REGRESSION: IAE for supported line in AudioSystem.getLine()

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b24
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: vtR10009 Date: 10/06/2003


      AudioSystem.getLine(Line.info) method should not throw IllegalArgumentException
      for lines that are supported by Java Sound framework.
      This bug causes failure of JCK test:
        api/javax_sound/sampled/LineListener/index.html#LineListener

      Note the test is passed by mantis (jdk1.4.2). So this is regression.
      To reproduce the bug run the following test with JDK build 1.5-beta-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) { String
              testCaseID = "LineListener2001";

              log.println("===== " + testCaseID + " =====");
          
              boolean failed = false;
              Line l = null;
          

          
              // get the default SourceDataLine
          
              DataLine.Info s_info = new DataLine.Info(SourceDataLine.class, null);
              Line.Info infos[] = AudioSystem.getSourceLineInfo( s_info );
          
              if( infos.length < 1 ) {
                  log.println("Line.Info array == 0");
                  return STATUS_PASSED;
              }
              try {
                  l = AudioSystem.getLine(infos[0]);
              } catch(SecurityException lue) {
                  log.println("SecurityException");
                  return STATUS_PASSED;
              } catch (LineUnavailableException e1) {
                  log.println("LUE");
                  return STATUS_PASSED;
              } catch (IllegalArgumentException iae) {
                  log.println("IllegalArgumentException should not be thrown "
                           + "for supported line");
                  iae.printStackTrace(log);
                  return STATUS_FAILED;
              }
              out.println("Passed.");
              return STATUS_PASSED;
          }
          
      } // end of test class
      ---------------------------Logs-------------------------------------------
      novo101:tmp$ javac -d . test.java
      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)

      ===== LineListener2001 =====
      Passed.
      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)

      ===== LineListener2001 =====
      IllegalArgumentException should not be thrown for supported line
      java.lang.IllegalArgumentException: Line unsupported: interface SourceDataLine
      supporting 4 audio formats, and buffers of at least 32 bytes
              at com.sun.media.sound.HeadspaceMixer.getLine(HeadspaceMixer.java:241)
              at javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:413)
              at test.run(test.java:47)
              at test.main(test.java:24)

      --------------------------------------------------------------------------
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fbomerssunw Florian Bomers (Inactive)
              Reporter:
              vitcsunw Vitc Vitc (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: